title: Can this C/C++ if() statement ever evaluate to TRUE?
body: <p>According to <strong>PC-lint</strong>, the following statement will never be <code>TRUE</code>:</p>
  
  <pre><code>if((variable &amp; 0x02) == 1)
  </code></pre>
  
  <p>I am using a C compiler for embedded systems that evaluates it to <code>TRUE</code> whenever the corresponding bit in <code>variable</code> is set. I guess the compiler is doing a <code>TRUE</code>/<code>FALSE</code> comparison of both sides of the <code>==</code> instead of comparing the resulting numbers. In other words, every time the expression <code>(varable &amp; 0x02)</code> is not zero (i.e. <code>TRUE</code>), the statement will also be <code>TRUE</code>, since the value <code>1  is also  TRUE</code> (not zero).</p>
  
  <p>I don't know if the <code>C/C++</code> standards clearly define how a compiler should behave in this case. Are there any <code>C/C++</code> experts out there who can answer this question based on what the standards (e.g. <code>C90, C99,</code> etc.) say?</p>
  
  <p>P.S.: In the statement above, "variable" is an unsigned char.</p>