The order in which operands in an expression are evaluated is undefined in C except at the sequence points.

Evaluation of an expression may produce side effects. At certain specified points in the execution sequence called sequence points, all side effects of previous evaluations shall be complete and no side effects of subsequent evaluations shall have taken place.

The following are the sequence points described:

Non-compliant Code Example

Compliant Solution

References

C99 5.1.2.3 Program execution
C99 Annex C Sequence points