Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7190367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:29:57+00:00 2026-05-28T19:29:57+00:00

I was reading through K&R and i came across this example about uncertainty in

  • 0

I was reading through K&R and i came across this example about uncertainty in behavior while evaluating expression like a[i]=i++;
The C99 spec in $6.5.2 says that

Between the previous and next sequence point an object shall have its stored value modified at most once by the evaluation of an expression. Furthermore, the prior value shall be read only to determine the value to be stored.

The above example from K&R holds good on the first statement. Please explain how does it fail on the second.

Does standard says anything about the order of evaluation of sub-expressions in case of the sequence points being involved. Eg. a[i++] || b[i++]. I know that these are evaluated from left to right but how can this be derived from the above statement or is it explicitly stated in the standard somewhere ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T19:29:57+00:00Added an answer on May 28, 2026 at 7:29 pm

    Does standard says anything about the order of evaluation of sub-expressions in case of the sequence points?

    The order of evaluation is well defined in case of conditional operators && as well as || and that is the very reason short circuiting works.

    It is explicitly specified by the c99 standard.

    Reference: c99 Standard

    Annex J: J.1 Unspecified behavior

    1 The following are unspecified:
    …..

    The order in which subexpressions are evaluated and the order in which side effects
    take place, except as specified for the function-call (), &&, ||, ?:, and comma
    operators (6.5).
    …..

    Further in,
    6.5.14 Logical OR operator

    4) Unlike the bitwise | operator, the || operator guarantees left-to-right evaluation; there is a sequence point after the evaluation of the first operand. If the first operand compares unequal to 0, the second operand is not evaluated.

    As well as for logical AND:

    6.5.13 Logical AND operator

    Unlike the bitwise binary & operator, the && operator guarantees left-to-right evaluation;
    if the second operand is evaluated, there is a sequence point between the evaluations of
    the first and second operands. If the first operand compares equal to 0, the second
    operand is not evaluated.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I came across this subject when I was reading through PrototypeJS's docs: its Identity
While reading Bruce Eckel i came across the following example: #include <cstdio> #include <cstdlib>
Whilst reading through K&R, I came across the integer to string function. I gave
I'm reading through K&R and came to the small section on register variables, and
I'm reading through an example in primer and something which it talks about is
I'm reading this article about creating a global hotkey. I've gone through the tutorial
Reading through this question on multi-threaded javascript, I was wondering if there would be
While reading through another question here, on creating a URL shortening service, it was
I'm reading through head first design patterns at the moment and while the book
I have been reading through the C++ FAQ and was curious about the friend

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.