Synopsis: | Use explicit parentheses when using multiple different operators in an expression |
Language: | C++ |
Severity Level: | 9 |
Category: | Control Flow |
Description: |
Without parentheses, it is easy to make mistakes when relying on precedence rules. Comparison and unary operators are excluded from this rule. Example: if ( a || b && c || d ) // wrong: incorrect reliance on precedence if ((a || (b && c) || d) // right: parentheses for correct evaluation |