title: C++ Exception "Skips" Try-Catch Clause in MSVC x64
body: <p>I'm writing a program in C++. The program has been working fine for Win32 (x86), and recently I've tried compiling it natively for x64. Of course, stuff didn't work right away.</p>
  
  <p>After debugging the problem, I've managed to reproduce it with this simple code snippet:</p>
  
  <pre><code>class MyException { };
  
  int main()
  {
      try {
          for (;;) {
              try {
                  std::cout &lt;&lt; "Throwing" &lt;&lt; std::endl;
  
                  throw MyException();
  
                  if (1 == 0) {
                      continue;
                  }
              } catch (const MyException&amp;) {
                  std::cout &lt;&lt; "Catch 1" &lt;&lt; std::endl;
              }
          }
      } catch (const MyException&amp;) {
          std::cout &lt;&lt; "Catch 2" &lt;&lt; std::endl;
      }
  
      std::cout &lt;&lt; "Done" &lt;&lt; std::endl;
  
      return 0;
  }
  </code></pre>
  
  <p>(I'll explain the <code>if (1==0)</code> clause soon)</p>
  
  <p>When compiling this code using MSVC for x86 (I've used 2010), the result is as expected:</p>
  
  <pre><code>Throwing
  Catch 1
  Throwing
  Catch 1
  Throwing
  Catch 1
  Throwing
  Catch 1
  ...
  </code></pre>
  
  <p>And so on, in an infinite loop.</p>
  
  <p>However, compiling this code for x64 results in:</p>
  
  <pre><code>Throwing
  Catch 2
  Done
  </code></pre>
  
  <p>The exception completely skips the inner catch clause!</p>
  
  <p>This only happens when the <code>if (1 ==0)</code> clause exists in my code. When I remove it, the exception is caught in "Catch 1" as expected.</p>
  
  <p>I've tried using other compilers:</p>
  
  <ul>
  <li>This bug also happens in VS 2012.</li>
  <li>MinGW and MinGW-w64 work as expected.</li>
  </ul>
  
  <p>My question: is this an MSVC bug, or is this some undefined behavior in C++ I'm missing?
  If this indeed is an MSVC bug, I'd love to hear some insight on the cause.</p>
  
  <p>Thanks.</p>