It's almost impossible to use longjmp
safely in a C++ program. Specifically:
C++11 18.10/4: A
setjmp
/longjmp
call pair has undefined behavior if replacing thesetjmp
andlongjmp
bycatch
andthrow
would invoke any non-trivial destructors for any automatic objects.
In this case, throwing an exception from croak
would invoke the destructor of e
, so calling longjmp
from there would give undefined behaviour. Calling the destructor yourself just makes the behaviour even less defined.