title: Visual Studio 2012 different values Release/Debug mode
body: <p>This code produces different values in MSVS 2012, Windows 7, when switching between Debug and Release mode:</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  int A[20000];
  
  int main() {
  
      int shift = 0;
      int Period = 30;
      //Fill array
      for(int i = 0; i &lt; 20000; i++) {
          A[i] = i * 2 + 123;
      }
  
      int sumTotal = 0;
      int sum = 0;
  
      for(int bars = Period + 10; bars &lt; 1000; bars++) {
          sum = 0;
          for(int i = 0; i&lt; Period; i++) {
              sum += A[bars - i];
          }
          sumTotal += sum;
      }
      cout &lt;&lt; sumTotal &lt;&lt; endl;
  }
  </code></pre>
  
  <p>Can you reproduce or find why? I've been testing with all kind of settings on project properties.</p>
  
  <ul>
  <li>Debug (the correct result): 32630400</li>
  <li>Release: 32814720</li>
  </ul>
  
  <p><code>/GS /GL /analyze- /W3 /Gy /Zc:wchar_t /I"C:\Program Files (x86)\Visual Leak Detector\include" /Z7 /Gm- /O2 /Fd"Release\vc110.pdb" /fp:precise /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /Gd /Oy- /Oi /MD /Fa"Release\" /EHsc /nologo /Fo"Release\" /Fp"Release\Testing.pch"</code></p>