...
The C standard, Section 6.5 [ISO/IEC 9899:2011], states:
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. If there are multiple allowable orderings of the subexpressions of an expression, the behavior is undefined if such an unsequenced side effect occurs in any of the orderings.
...
The following sequence points are defined in Annex C of the C standard [ISO/IEC 9899:2011]:
- Between the evaluations of the function designator and actual arguments in a function call and the actual call.
- Between the evaluations of the first and second operands of the following operators:
- logical AND:
&&
- logical OR:
||
- comma:
,
- logical AND:
- Between the evaluations of the first operand of the conditional
?:
operator and whichever of the second and third operands is evaluated. - The end of a full declarator.
- Between the evaluation of a full expression and the next full expression to be evaluated. The following are full expressions:
- an initializer that is not part of a compound literal
- the expression in an expression statement
- the controlling expression of a selection statement (
if
orswitch
) - the controlling expression of a
while
ordo
statement - each of the (optional) expressions of a
for
statement - the (optional) expression in a
return
statement
- Immediately before a library function returns.
- After the actions associated with each formatted input/output function conversion specifier.
- Immediately before and immediately after each call to a comparison function, and also between any call to a comparison function and any movement of the objects passed as arguments to that call.
...
The CERT Oracle Secure Coding Standard for Java: EXP05-J. Do not write more than once to the same variable within an expression
ISO/IEC 9899:2011 Section Section 5.1.2.3, "Program execution," Section 6.5, "Expressions," and Annex C, "Sequence points"
...