...
Attempting to modify an object multiple times between sequence points may cause that object to take on an unexpected value, which can lead to unexpected program behavior.
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
EXP30-C | Medium | Probable | Medium | P8 | L2 |
Automated Detection
Tool | Version | Checker | Description | ||||||
---|---|---|---|---|---|---|---|---|---|
Astrée |
| evaluation-order | Fully checked | ||||||
Clang |
| -Wunsequenced | Detects simple violations of this rule, but does not diagnose unsequenced function call arguments. | ||||||
Compass/ROSE |
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 | |||||||
GCC |
|
Can detect violations of this rule when the | ||||||||
Klocwork |
| PORTING.VAR.EFFECTS |
LDRA tool suite |
| 35 D, 1 Q, 9 S, 30 S, 134 S | Partially implemented | ||||||
Parasoft C/C++test |
|
|
| MISRA2004-12_2_{a,b,c,d} | Fully implemented | |||||||
Polyspace Bug Finder | R2016a | MISRA2012-RULE-13_2 | Fully implemented | ||||||
PRQA QA-C |
| 0400 [U] | Fully implemented | ||||||
RuleChecker |
| evaluation-order | Fully checked | ||||||
Splint |
|
SonarQube C/C++ Plugin |
| IncAndDecMixedWithOtherOperators |
PVS-Studio | 6.22 | V567 | General analysis rule |
Related Vulnerabilities
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
...
Key here (explains table format and definitions)
Taxonomy | Taxonomy item | Relationship |
---|---|---|
CERT C | EXP50-CPP. Do not depend on the order of evaluation for side effects | Prior to 2018-01-12: CERT: Unspecified Relationship |
CERT Oracle Secure Coding Standard for Java | EXP05-J. Do not follow a write by a subsequent write or read of the same object within an expression | Prior to 2018-01-12: CERT: Unspecified Relationship |
ISO/IEC TR 24772:2013 | Operator Precedence/Order of Evaluation [JCW] | Prior to 2018-01-12: CERT: Unspecified Relationship |
ISO/IEC TR 24772:2013 | Side-effects and Order of Evaluation [SAM] | Prior to 2018-01-12: CERT: Unspecified Relationship |
MISRA C:2012 | Rule 12.1 (advisory) | Prior to 2018-01-12: CERT: Unspecified Relationship |
CWE 2.11 | CWE-758 | 2017-07-07: CERT: Rule subset of CWE |
CERT-CWE Mapping Notes
Key here for mapping notes
...
- Undefined behavior that results from anything other than reading and writing to a variable twice without an intervening sequence point.
Bibliography
[ISO/IEC 9899:2011] | 6.5, "Expressions" 6.5.2.2, "Function Calls" 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 |
...
...