<!DOCTYPE qhelp PUBLIC
  "-//Semmle//qhelp//EN"
  "qhelp.dtd">
<qhelp>


<overview>
<p>This rule finds Boolean values (i.e. expressions that will always have the value 0 or 1)
which are used in a bit-wise context.</p>

<p>Due to the restricted range of Boolean values, only the
lowest bit could possibly be set, and thus applying a bit operation
is rarely what is intended. Violations are often indicative of a typo
or a misunderstanding of operator precedence. Another common source
of defects is using the bitwise AND operator instead of logical AND.</p>

</overview>
<recommendation>
<p>Carefully inspect the flagged expressions to make sure they exhibit the intended behavior.
Consider adding parentheses if necessary, or replacing bitwise operations with logical equivalents.
If the code is indeed correct, consider extracting the Boolean value to a variable to make it clear
what is happening.</p>

</recommendation>
<example><sample src="BoolValueInBitOp.cpp" />




</example>
</qhelp>
