Skip to content

Instantly share code, notes, and snippets.

@mirekfranc
Created April 24, 2015 21:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mirekfranc/e668f43a0fe3d05248f9 to your computer and use it in GitHub Desktop.
Save mirekfranc/e668f43a0fe3d05248f9 to your computer and use it in GitHub Desktop.
goto before construction causes destruction; guaranteed by the C++ standard
#include <iostream>
class A
{
public:
A () { std::cout << "a"; }
~A () { std::cout << "A"; }
};
int i = 1;
int main ()
{
out:
A a;
if (i--)
goto out;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment