title: Is jumping over a variable initialization ill-formed or does it cause undefined behaviour?
body: <p>Consider this code:</p>
  
  <pre><code>void foo()
  {
      goto bar;
      int x = 0;
      bar: ;
  }
  </code></pre>
  
  <p>GCC and Clang <a href="https://gcc.godbolt.org/z/qcfmof" rel="noreferrer">reject it</a>, because the jump to <code>bar:</code> bypasses variable initialization. MSVC doesn't complain at all (except using <code>x</code> after <code>bar:</code> causes a warning).</p>
  
  <p>We can do a similar thing with a <code>switch</code>:</p>
  
  <pre><code>void foo()
  {
      switch (0)
      {
          int x = 0;
          case 0: ;
      }
  }
  </code></pre>
  
  <p>Now all three compilers <a href="https://gcc.godbolt.org/z/4F3diV" rel="noreferrer">emit errors</a>.</p>
  
  <p>Are those snippets ill-formed? Or do they cause UB?</p>
  
  <p>I used to think that both were ill-formed, but I can't find the revelant parts of the standard. <a href="http://eel.is/c++draft/stmt.goto" rel="noreferrer">[stmt.goto]</a> doesn't say anything about this, and neither does <a href="http://eel.is/c++draft/stmt.switch" rel="noreferrer">[stmt.select]</a>.</p>