Using setjmp/longjmp
The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.
The latest version of this topic can be found at Using setjmp-longjmp.
When setjmp and longjmp are used together, they provide a way to execute a non-local goto. They are typically used to pass execution control to error-handling or recovery code in a previously called routine without using the standard calling or return conventions.
However, because |
If you decide to use setjmp/longjmp in a C++ program, also include SETJMP.H or SETJMPEX.H to assure correct interaction between the functions and C++ exception handling. If you use /EH to compile, destructors for local objects are called during the stack unwind. If you use /EHs to compile, and one of your functions calls a function that uses nothrow and the function that uses nothrow calls longjmp, then the destructor unwind might not occur, depending on the optimizer.
In portable code, when a non-local goto that calls longjmp is executed, correct destruction of frame-based objects might be unreliable.