카테고리 없음

longjmp and destructor

steloflute 2016. 4. 29. 23:30
http://en.cppreference.com/w/cpp/utility/program/longjmp


No destructors for automatic objects are called. If replacing of std::longjmp with throw and setjmp with catchwould execute a non-trivial destructor for any automatic object, the behavior of such std::longjmp is undefined.


longjmp를 쓰면 destructor가 안 불리네.

C++에서는 throw, catch를 써야 한다. (malloc, free 대신에 new, delete를 쓰는 것처럼)