goto and RAII in C++
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/3179936/goto-out-of-a-block-do-destructors-get-called">Goto out of a block: do destructors get called?</a>  </p>
</blockquote>



<p>I know that goto operator both in C and C++ is useless in almost all situations, but i want to know the answer for this question only by interest, it has no practical meaning.</p>

<p>Does C++ standard guarantees that in such situations destructors of objects must be called properly?</p>

<pre><code>#include &lt;iostream&gt;

class Foo
{
public:
   Foo() { std::cout &lt;&lt; "Foo::Foo() \n"; }
   ~Foo() { std::cout &lt;&lt; "Foo::~Foo() \n"; }
};

int main()
{
   {
      std::size_t i = 0;
      _1:
      Foo instance;
      if (!++i)
      {
         goto _1;
      }
   }

   {
      Foo instance;
      goto _2;
   }

   _2:
   ;
}
</code></pre>

<p><a href="http://liveworkspace.org/code/06031e6699c8fddda94b8594ccab1387" rel="nofollow">http://liveworkspace.org/code/06031e6699c8fddda94b8594ccab1387</a></p>

<p>And what about other stange situations with goto and C++ RAII?</p>

<p>It would be really cool if you can post here the quotes from the C++ standard.</p>
