...
According to the C Standard, section subclause 6.5 [ISO/IEC 9899:2011],
Except as specified later, side effects and value computations of subexpressions are unsequenced.
...
- The order in which the arguments to a function are evaluated (C Standard, section subclause 6.5.2.2, "Function Calls")
- The order of evaluation of the operands in an assignment statement (C Standard, section subclause 6.5.16, "Assignment Operators")
- The order in which any side effects occur among the initialization list expressions is unspecified. In particular, the evaluation order need not be the same as the order of subobject initialization (C Standard, section subclause 6.7.9, "Initialization")
This recommendation is related to EXP30-C. Do not depend on order of evaluation between sequence points, but it focuses on behavior that is nonportable or potentially confusing.
...
EXP10-EX4: The left operand of a comma operator is evaluated before the right operand is evaluated. There is a sequence point in between.
Note that while whereas commas serve to delimit multiple arguments in a function call, these commas are not considered comma operators. Multiple arguments of a function call may be evaluated in any order, with no sequence points between each other.
...
Tool | Version | Checker | Description | ||||||
---|---|---|---|---|---|---|---|---|---|
|
| Could detect violations of this recommendation by searching for the following pattern:
| |||||||
| EVALUATION_ORDER | Can detect the specific instance where a statement contains multiple side effects on the same value with an undefined evaluation order because the statement may behave differently with different compiler flags or different compilers or platforms | |||||||
| 35 D | Fully implemented | |||||||
PRQA QA-C |
| 3226 | Partially implemented |
...
Bibliography
[ISO/IEC 9899:2011] | Section Subclause 6.5, "Expressions" |
...