In C, most operators do not have a standard defined order for evaluation for their operands. This means that the order in which the operands are evaluated can be implementation-defined. However, there are certain points in the execution sequence called sequence points, where all side effects of previous evaluations are guaranteed to be complete and no side effects from subsequent evaluations have yet been performed.
The standard defines several sequence points, including the end of the first operand of the logical AND (&&), logical OR (||), conditional (?), and comma (,) operators. At these points, the values of the operands will have been fully evaluated and the program can proceed with the evaluation of the next expressions safely.
Sequence points are specific points in a C program's execution where the values of all expressions evaluated so far will have been fully updated, and no side effects from subsequent evaluations have taken place yet. These points are defined in the C standard and include:
- The end of the first operand of the logical AND (&&), logical OR (||), conditional (?), and comma (,) operators.
- After the evaluation of the left operand of the ternary operator (?:).
- Before a function call and after the return from the function call.
- At the end of a full expression.
At these sequence points, the values of all variables in the program are guaranteed to be updated to their latest values, and the program can proceed with the evaluation of the next expressions safely.
It's important to note that if you don't use Sequence points and if you are using any kind of side effects in your expressions the output of your program may be unexpected and non-deterministic.