Is it safe to use longjmp and setjmp in C++ on linux/gcc with regards to the following?
- Exception handling (I’m not implementing exception handling using longjmp/setjmp. I want to know what side effects longjmp/setjmp will have on standard exception handling)
*thispointer- Signals
- Smart pointers (boost’s shared and intrusive pointers)
- Anything else you can think of.
setjmp()/longjmp()completely subvert stack unwinding and therefore exception handling as well as RAII (destructors in general).From 18.7/4 “Other runtime support” in the standard:
So the bottom line is that
setjmp()/longjmp()do not play well in C++.