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
See
- CERT, EXP46-C. - Do not use a bitwise operator with a Boolean-like operand