...
Evaluation of an expression may produce side effects. At certain specified specific points in the execution sequence called sequence points, all side effects of previous evaluations shall be complete have completed and no side effects of subsequent evaluations shall have yet taken place.
The following are the sequence points defined by C99:
...
Between the previous and next sequence point an object can only have its stored value modified at most once by the evaluation of an expression. Additionally, the prior value
can be read only to determine the value to be stored.
This rule means that statements such as:
Code Block |
---|
i = i + 1;
|
are allowed while statements like:
Code Block |
---|
i = i++;
|
are not allowed because it modifies the same value twice.
Non-compliant Code Example 1
...
- ISO/IEC 9899-1999 Section 5.1.2.3 Program execution
- ISO/IEC 9899-1999 Section 6.5 Expressions
- ISO/IEC 9899-1999 Annex C Sequence points
- comp.lang.c FAQ list - Question Questions 3.1, 3.2, 3.3, 3.3b, 3.7, 3.8, 3.9