...
Failure to understand the evaluation order of expressions containing side effects can result in unexpected output.
Rule | Severity | Likelihood | Detectable | RepairableRemediation Cost | Priority | Level |
|---|---|---|---|---|---|---|
EXP05-J | Low | Unlikely | Yes | NoMedium | P2 | L3 |
Automated Detection
Detection of all expressions involving both side effects and multiple operator precedence levels is straightforward. Determining the correctness of such uses is infeasible in the general case; heuristic warnings could be useful.
| Tool | Version | Checker | Description | ||||||
|---|---|---|---|---|---|---|---|---|---|
| Parasoft Jtest |
| CODSTACERT.READEXP05.CID | Avoid using increment or decrement operators in nested expressions | ||||||
| PVS-Studio |
| V6044 | |||||||
| SonarQube |
| S881 | Increment (++) and decrement (--) operators should not be used in a method call or mixed with other operators in an expression |
...
EXP30-C. Do not depend on the order of evaluation for side effects | |
EXP50-CPP. Do not depend on the order of evaluation for side effects | |
| ISO/IEC TR 24772:2010 | Side Effects and Order of Evaluation [SAM] |
...