Next: Ordering of Operands, Previous: Sequence Points, Up: Order of Execution [Contents][Index]
Ordering requirements are loose with the postincrement and postdecrement operations (see Postincrement/Postdecrement), which specify side effects to happen “a little later.” They must happen before the next sequence point, but that still leaves room for various meanings. In this expression,
z = x++ - foo ()
it’s unpredictable whether
x gets incremented before or after
calling the function
foo refers to
it might see the old value or it might see the incremented value.
In this perverse expression,
x = x++
x will certainly be incremented but the incremented value may
not stick. If the incrementation of
x happens after the
x, the incremented value will remain in place.
But if the incrementation happens first, the assignment will overwrite
that with the not-yet-incremented value, so the expression as a whole