Restrictions on Termination Handlers
You can't use a goto
statement to jump into a __try
statement block or a __finally
statement block. Instead, you must enter the statement block through normal flow of control. (You can, however, jump out of a __try
statement block.) Also, you can't nest an exception handler or termination handler inside a __finally
block.
Some kinds of code permitted in a termination handler produce questionable results, so you should use them with caution, if at all. One is a goto
statement that jumps out of a __finally
statement block. If the block executes as part of normal termination, nothing unusual happens. But if the system is unwinding the stack, that unwinding stops. Then, the current function gains control as if there were no abnormal termination.
A return
statement inside a __finally
statement block presents roughly the same situation. Control returns to the immediate caller of the function that contains the termination handler. If the system was unwinding the stack, this process is halted. Then, the program proceeds as if no exception had been raised.
See also
Writing a termination handler
Structured Exception Handling (C/C++)
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for