Synopsis: | The right-hand operand of the "&&" or "||" operator shall not contain any side-effects. |
Language: | C |
Severity Level: | 6 |
Category: | Expressions |
Description: |
Justification The right-hand operand of a "&&" or "||" is conditionally executed. Besides, the precedence of operators in C is not intuitive. Example 1 if ((a > b) && (i++ != 0)) /* WRONG: i not always changed */ Example 2 if ((a > b) && (i != 0)) /* RIGHT */ ... } Example 3 if (a > b) { i++; /* RIGHT */ } |