The bitwise operators &, | can be mistaken for the boolean operators && and ||.

This rule raises an issue when & or | is used in a boolean context.

Noncompliant Code Example

if (a & b) { ... } // Noncompliant; & used in error

Compliant Solution

if (a && b) { ... }

Exceptions

When a file contains other bitwise operations, (^, <<, >>>, >>, ~, &=, ^=, |=, <<=, >>=, >>>= and & or | used with a numeric literal as the right operand) all issues in the file are ignored, because it is evidence that bitwise operations are truly intended in the file.