Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Tool

Version

Checker

Description

Splint

Include Page
Splint_VSplint_V

 

 

GCC

Include Page
GCC_VGCC_V

 

Can detect violations of this rule when the -Wsequence-point flag is used.

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.

Coverity

Include Page
Coverity_V
Coverity_V

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.

GCC

Include Page
GCC_V
GCC_V

 

Can detect violations of this rule when the -Wsequence-point flag is used.

LDRA tool suite

Include Page
LDRA_V
LDRA_V

35 D
1 Q
9 S
30 S
134 S

Fully implemented.

PRQA QA-C
Include Page
PRQA_V
PRQA_V

0400 [U]
0401 [U]
0402 [U]
0403 [U]

Fully implemented.

Splint

Include Page
Splint_V
Splint_V

 

 

Related Vulnerabilities

Search for vulnerabilities resulting from the violation of this rule on the CERT website.

...

CERT C++ Secure Coding StandardEXP30-CPP. Do not depend on order of evaluation between sequence points
CERT Oracle Secure Coding Standard for JavaEXP05-J. Do not write more than once to the same variable within an expression
ISO/IEC TR 24772JCW Operator precedence/order of evaluation" and "SAM evaluation [JCW]
Side-effects and order of evaluation [SAM]
MISRA-CRule 12.1 (advisory): Limited dependence should be placed on C’s operator precedence rules in expressions

Bibliography

[ISO/IEC 9899:2011]Section 5.1.2.3, "Program Execution," section 6.5, "Expressions," and Annex C, "Sequence Points"
[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]