title: What is the performance implication of converting to bool in C++?
body: <p><em>[This question is related to but not the same as <a href="https://stackoverflow.com/questions/206106/is-a-safe-way-to-convert-to-bool-in-c">this one</a>.]</em></p>
  
  <p>My compiler warns about implicitly converting or casting certain types to bool whereas explicit conversions do not produce a warning:</p>
  
  <pre><code>long t = 0;
  bool b = false;
  b = t;                    // performance warning: forcing long to bool
  b = (bool)t;              // performance warning
  b = bool(t);              // performance warning
  b = static_cast&lt;bool&gt;(t); // performance warning
  b = t ? true : false;     // ok, no warning
  b = t != 0;               // ok
  b = !!t;                  // ok
  </code></pre>
  
  <p>This is with Visual C++ 2008 but I suspect other compilers may have similar warnings.</p>
  
  <p>So my question is: what is the performance implication of casting/converting to <code>bool</code>?  Does explicit conversion have better performance in some circumstance (e.g., for certain target architectures or processors)?  Does implicit conversion somehow confuse the optimizer?</p>
  
  <p>Microsoft's <a href="http://msdn.microsoft.com/en-us/library/b6801kcy.aspx" rel="noreferrer">explanation</a> of their warning is not particularly helpful.  They imply that there is a good reason but they don't explain it.</p>