Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Non-Compliant Code Example

Code Block
bgColor#FFCCCC
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
bgColor#ccccff
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.

...