The information in this article applies to:
SYMPTOMSWhen using Structured Exception Handling (SEH), returning out of a finally body results in a return from the containing procedure scope. For example, in the following code fragment, the return in the finally block results in a return from func():
CAUSE
A return from within a __finally is equivalent to a goto to the closing
brace in the enclosing function [for example, func()]. This is allowed,
but has consequences that should normally be avoided.
RESOLUTION
This is by design. It makes it possible for a finally handler to stop an
unwind and return a status. This is what is referred to as a collided
unwind.
This does not have identical semantics because the exception filters
higher up the exception stack will not be executed. However, ensuring
that both phases of exception handling progress to the same depth is a
more robust solution.
MORE INFORMATIONNormally this behavior is transparent to any higher-level exception handling code. If, however, a filter function, as a side effect, stores information that it expects to process in an exception handler, then it may or may not be transparent. Storing such information in a filter function should be avoided because it is always possible that the exception handler will not be executed because the unwind is preempted. In the absence of storing such side effects, it will be transparent that an exception occurred and an attempted unwind occurred if one of the descendent functions has a try/finally block with an finally clause that preempts the unwind. Additional query words: 3.10 3.50 4.00
Keywords : kbNTOS310 kbNTOS350 kbNTOS351 kbWinOS95 |
Last Reviewed: September 23, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |