...
The order of evaluation for function arguments is unspecified:. The call to func()
in this noncompliant code example has undefined behavior because there are no sequence points between the argument expressions.
Code Block | ||||
---|---|---|---|---|
| ||||
func(i++, i); |
The call to func()
has undefined behavior because there are no sequence points between the argument expressions. The first (left) argument expression reads the value of i
(to determine the value to be stored) and then modifies i
. The second (right) argument expression reads the value of i
between the same pair of sequence points as the first argument, but not to determine the value to be stored in i
. This additional attempt to read the value of i
has undefined behavior.
...
Tool | Version | Checker | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
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 | ||||||||||
| 35 D | Fully implemented | |||||||||||
PRQA QA-C |
| 0400 [U] | Fully implemented | ||||||||||
Splint |
|
|
|
...