For the latest documentation on Visual Studio 2017, see Visual Studio 2017 Documentation.
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.
If you decide to use
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
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.