...
Non-Compliant Code Example
Code Block | ||
---|---|---|
| ||
int ienum { max = 15 }; int max i = /* initialize to user supplied value */; if ( (i >= 0 && (i++) <= max) ) { /* code */ } |
...
In this compliant solution, the behavior is much cleareridentical and clearly apparent.
Code Block | ||
---|---|---|
| ||
int ienum { max = 15 }; int max i = /* initialize to user supplied value */; if ( (i >= 0) { && i++; if (i <= max) ) { i++; /* code */ } } |
Risk Assessment
Attempting to modify an object that is the second operand to the logical OR or AND operator may cause that object to take on an unexpected value. This can lead to unintended program behavior.
...