title: MSVS/C++: fastest always-false condition that won't be optimized away?
body: <p>I have this code:</p>
  <pre><code>if (false)
  {
      ...code... 
  }
  </code></pre>
  <p>that the compiler is optimizing away in release builds. I realize it's being removed because it'll never be reached, but I want the code inside to be present in release builds (for reasons).</p>
  <p>A simple solution is to make the condition dependent on a function that the compiler won't evaluate. Ex:</p>
  <pre><code>if (cos(0.5) == 1)
  {
      ...code...
  }
  </code></pre>
  <p>This is not optimized away because the compiler won't evaluate cos(x).</p>
  <p>However, I'd like this always-false condition to take as little time as possible to execute because the never-executed code block sits in a larger piece of code whose performance is critical. I know cos(x) is a fast function to evaluate, but are there faster functions I could use in its place (functions which will never be optimized away)? I'm trying to expend as few CPU cycles as possible on this test.</p>
  <p>Or more specifically, how can I write a function that will always return false, that the compiler can't evaluate, that will expend fewer CPU cycles than cos(x)? Naive attempts like:</p>
  <pre><code>bool alwaysFalse(){return false;}
  
  bool alwaysFalse(){return 1 == 2;}
  
  bool alwaysFalse(){return (1-2) == 3;}
  </code></pre>
  <p>don't work because the compiler is smart enough to figure them out and optimize my code away.</p>