Why is this an issue?
The use of non-short-circuit logic in a boolean context is likely a mistake - one that could cause serious program errors as conditions are
evaluated under the wrong circumstances.
Noncompliant code example
if(getTrue() | getFalse()) { ... } // Noncompliant; both sides evaluated
Compliant solution
if(getTrue() || getFalse()) { ... } // true short-circuit logic
Resources
- CERT, EXP46-C. - Do not use a bitwise operator with a Boolean-like operand