Created
August 1, 2014 20:52
-
-
Save FlyingJester/763a61d9aeed88f238aa to your computer and use it in GitHub Desktop.
setjmp/longjmp Causing leaks!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //g++ -std=c++11 setjmp_unique_ptr.cpp -o demo | |
| #include <cstdio> | |
| #include <memory> | |
| #include <csetjmp> | |
| struct Test { | |
| Test(){ | |
| std::fputs("Created Test.\n", stdout); | |
| } | |
| ~Test(){ | |
| std::fputs("Destroyed Test.\n", stdout); | |
| } | |
| }; | |
| int main(){ | |
| std::jmp_buf f; | |
| if(setjmp(f)){return 0;} | |
| std::unique_ptr<Test> TestHolder(new Test()); | |
| longjmp(f, 1); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment