Evaluation of an expression may produce side effects. At specific points during execution, known as sequence points, all side effects of previous evaluations have completed, and no side effects of subsequent evaluations have yet taken place.
...
Code Block | ||||
---|---|---|---|---|
| ||||
/* i is modified twice between sequence points. */ i = ++i + 1; /* i is read other than to determine the value to be stored. */ a[i++] = i; |
Noncompliant Code Example
...
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
EXP30-C | mediumMedium | probableProbable | mediumMedium | P8 | L2 |
Automated Detection
Tool | Version | Checker | Description | ||||||
---|---|---|---|---|---|---|---|---|---|
|
| Can detect simple violations of this rule. It needs to examine each expression and make sure that no variable is modified twice in the expression. It also must check that no variable is modified once, then read elsewhere, with the single exception that a variable may appear on both the left and right of an assignment operator | |||||||
| EVALUATION_ORDER | Can detect the specific instance where a statement contains multiple side effects on the same value with an undefined evaluation order because, with different compiler flags or different compilers or platforms, the statement may behave differently | |||||||
| CC2.EXP30 | Fully implemented | |||||||
|
| Can detect violations of this rule when the | |||||||
| 35 D | Fully implemented | |||||||
PRQA QA-C |
| 0400 [U] | Fully implemented | ||||||
|
|
|
...
[ISO/IEC 9899:2011] | Subclause 6.5, "Expressions," and Annex C, "Sequence Points" | ||
[Saks 2007] | |||
[Summit 2005] | Questions 3.1, 3.2, 3.3, 3.3b, 3.7, 3.8, 3.9, 3.10a, 3.10b, and 3.11 | [Saks 2007] |
...