Re: Being Confused by /EH Exception Handling Model
"Doug Harrison [MVP]" wrote:
That said, it is subtle, and the documentation could say that
/EHc doesn't necessarily prevent the compiler from catching
exceptions thrown by extern "C" functions. I would expect a try
block that contains a mixture of function calls like f4 and
ordinary functions that throw to catch f4's exception, as
optimization won't suppress try/catch in that case, but local
objects associated solely with unwinding f4 would not be
destroyed.
Actually, MSDN mentions something similar, though in quite a vague
language:
<quote>
[the paragraph about /EHc switch]
When an exception is caught, the compiler invokes the class
destructor or destructors for the object or objects that are in
the same scope as the exception. When an exception is not caught,
those destructors are not run.
</quote>
I think that "in the same scope as the exception" part implies
that objects in other scopes won't be properly destroyed.
Otherwise, I don't know how to interpret that.
Alex