title: Visual C++ 2008 bug?
body: <p>The very simple code (under MS Visual C++ 2008 Express):</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  int main()
  {
      for (int a=1; 2*a&lt;=7; a++)
          cout &lt;&lt; a &lt;&lt; endl;
      return 0;
  }
  </code></pre>
  
  <p><strong>Debug</strong> mode gives me <strong>correct</strong> result:</p>
  
  <pre><code>1
  2
  3
  </code></pre>
  
  <p>But <strong>Release</strong> mode gives me <strong>wrong</strong> result:</p>
  
  <pre><code>1
  2
  </code></pre>
  
  <p>Well, I understand possible answers "use 2*a&lt;8"; "why not a&lt;=3", "a&lt;4".</p>
  
  <p>I don't want to change the code, 'cause it is correct code (working well in Debug mode, all variables are initialized well, etc).</p>
  
  <ul>
  <li>Have you the same bug with Visual C++ 2008 Express?</li>
  <li>Is this bug present in younger versions (2010, 2012)?</li>
  <li>How to avoid this bug?</li>
  <li>Is there SP for fixing it?</li>
  <li>Maybe to change some compile options (not default options)?</li>
  </ul>
  
  <hr>
  
  <p><strong>Update:</strong></p>
  
  <p>when I write</p>
  
  <pre><code>cout &lt;&lt; a+1 &lt;&lt; endl;
  </code></pre>
  
  <p>or</p>
  
  <pre><code>cout &lt;&lt; 2*a &lt;&lt; endl;
  </code></pre>
  
  <p>it works/compiles correct (<strong>3</strong> rows of output).</p>
  
  <hr>
  
  <p><strong>Note:</strong>
  I tried on different computers with VC++ 2008 Express. The same behavior.</p>