...
This compliant solution follows the guidance of PRE00-C. Prefer inline or static functions to function-like macros by defining an inline function iabs() to replace the ABS() macro. Unlike the ABS() macro, which operates on operands of any type, the iabs() function will truncate arguments of types wider than int whose value is not in range of the latter type.
...
Invoking an unsafe macro with an argument that has side effects may cause those side effects to occur more than once. This practice can lead to unexpected program behavior.
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
|---|---|---|---|---|---|
PRE31-C | Low | Unlikely | Low | P3 | L3 |
Automated Detection
Tool | Version | Checker | Description | ||||||
|---|---|---|---|---|---|---|---|---|---|
| ASSERT_SIDE_EFFECTS | Partially implemented Can detect the specific instance where assertion contains an operation/function call that may have a side effect | |||||||
| ECLAIR |
| CC2.EXP31 CC2.PRE31 | Fully implemented | ||||||
| LDRA tool suite |
| 9 S, 562 S, 572 S, 35 D, 1 Q | Fully implemented | ||||||
| Parasoft C/C++test |
|
|
| CODSTA-123 |
| , CODSTA-150, CODSTA-150_b, CODSTA-150_c | Implemented | ||||||||
| Polyspace Bug Finder | R2016a | MISRA2012-RULE-13_2 | Partial | ||||||
| PRQA QA-C |
| 3454, 3455, 3456 | Fully implemented | ||||||
| PRQA QA-C++ |
| 3225, 3226, 3227, 3228, 3229 |
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 |
|---|
Bibliography
| [Dewhurst 2002] | Gotcha #28, "Side Effects in Assertions" |
| [ISO/IEC 9899:2011] | Subclause 6.5.1.1, "Generic Selection" |
| [Plum 1985] | Rule 1-11 |
...
...