Expressions (EXP)
- EXP00-C. Use parentheses for precedence of operation
- EXP02-C. Be aware of the short-circuit behavior of the logical AND and OR operators
- EXP03-C. Do not assume the size of a structure is the sum of the sizes of its members
- EXP05-C. Do not cast away a const qualification
- EXP07-C. Do not diminish the benefits of constants by assuming their values in expressions
- EXP08-C. Ensure pointer arithmetic is used correctly
- EXP09-C. Use sizeof to determine the size of a type or variable
- EXP10-C. Do not depend on the order of evaluation of subexpressions or the order in which side effects take place
- EXP11-C. Do not make assumptions regarding the layout of structures with bit-fields
- EXP12-C. Do not ignore values returned by functions
- EXP13-C. Treat relational and equality operators as if they were nonassociative
- EXP14-C. Beware of integer promotion when performing bitwise operations on integer types smaller than int
- EXP15-C. Do not place a semicolon on the same line as an if, for, or while statement
- EXP16-C. Do not compare function pointers to constant values
- EXP19-C. Use braces for the body of an if, for, or while statement
- EXP20-C. Perform explicit tests to determine success, true and false, and equality
Information for Editors
In order to have a new guideline automatically listed above be sure to label it exp and recommendation .
Risk Assessment Summary
| Rule | Severity | Likelihood | Detectable | Repairable | Priority | Level |
|---|---|---|---|---|---|---|
| EXP00-C | Low | Probable | Yes | Yes | P6 | L2 |
| EXP02-C | Low | Unlikely | No | No | P1 | L3 |
| EXP03-C | High | Unlikely | No | No | P3 | L3 |
| EXP05-C | Medium | Probable | No | No | P4 | L3 |
| EXP07-C | Low | Unlikely | No | No | P1 | L3 |
| EXP08-C | High | Probable | No | No | P6 | L2 |
| EXP09-C | High | Unlikely | No | Yes | P6 | L2 |
| EXP10-C | Medium | Probable | No | Yes | P8 | L2 |
| EXP11-C | Medium | Probable | No | No | P4 | L3 |
| EXP12-C | Medium | Unlikely | Yes | No | P4 | L3 |
| EXP13-C | Low | Unlikely | Yes | Yes | P3 | L3 |
| EXP14-C | Low | Likely | No | No | P3 | L3 |
| EXP15-C | High | Likely | Yes | Yes | P27 | L1 |
| EXP16-C | Low | Likely | Yes | No | P6 | L2 |
| EXP19-C | Medium | Probable | Yes | Yes | P12 | L1 |
| EXP20-C | Medium | Probable | Yes | Yes | P12 | L1 |
Related Rules and Recommendations
| FLP01-C. Take care in rearranging floating-point expressions |
| PRE01-C. Use parentheses within macros around parameter names |
| PRE02-C. Macro replacement lists should be parenthesized |


