Next: Postincrement and Ordering, Previous: Associativity and Ordering, Up: Order of Execution [Contents][Index]
There are some points in the code where C makes limited guarantees about the order of operations. These are called sequence points. Here is where they occur:
The commas that separate arguments in a function call are not comma operators, and they do not create sequence points. The rule for function arguments and the rule for operands are different (see Ordering of Operands).
If the function to be called is not constant—that is, if it is computed by an expression—all side effects in that expression are carried out before calling the function.
The ordering imposed by a sequence point applies locally to a limited range of code, as stated above in each case. For instance, the ordering imposed by the comma operator does not apply to code outside that comma operator. Thus, in this code,
(x = 5, foo (x)) + x * x
the sequence point of the comma operator orders x = 5
before
foo (x)
, but x * x
could be computed before or after
them.
Next: Postincrement and Ordering, Previous: Associativity and Ordering, Up: Order of Execution [Contents][Index]