Is there a sequence point between the two assignments in the following code:
f(f(x=1,1),x=2);
A sequence point defines any point in a computer program's execution at which it is guaranteed that all side effects of previous evaluations will have been performed, and no side effects from subsequent evaluations have yet been performed.
Sequence point rules (until C++11) A sequence point is a point in the execution sequence where all side effects from the previous evaluations in the sequence are complete, and no side effects of the subsequent evaluations started.
The comma operator has the lowest precedence of any C operator, and acts as a sequence point.
Do not depend on the order of evaluation for side effects unless there is an intervening sequence point. If a side effect on a scalar object is unsequenced relative to either a different side effect on the same scalar object or a value computation using the value of the same scalar object, the behavior is undefined.
No there isn't. The standard is indeed ambiguous in this case.
If you want to confirm that, gcc has this really cool option -Wsequence-point
and in this case it will warn you that the operation may be undefined
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With