This is unspecified, and in the case of C99 the corresponding quote is 6.5 / 3:
Except as noted below (to call the function () , && , || , ?: And commas), the order in which subexpressions are evaluated and the order in which side effects occur are not defined.
In your example, foo() and bar() are subexpressions of the full expression i = foo() + bar() .
The βlaterβ for function calls is not directly relevant here, but for reference it is 6.5.2.2/10:
The order of evaluation of the function pointer, the actual arguments and subexpressions is not specified in the actual arguments, but there is a sequence point before the actual call.
For && it 6.5.13 / 4:
Unlike bitwise binary code and operator, operator guarantees && rating from left to right; after the point the score of the first operand.
Since + not on the list of operators above, && and + are "different" in the same way that && and & "unlike", and that is exactly what you are asking for. Unlike && , + does not guarantee an assessment from left to right.
Steve jessop
source share