[cxx-abi-dev] Details missing for EH 2.4.1 Overview of Throw Processing

John McCall rjmccall at apple.com
Fri Dec 16 20:07:13 UTC 2011


On Dec 15, 2011, at 11:28 PM, Dennis Handly wrote:
> I'm trying to see how the code for a throw is generated and to see if
> our compiler is compliant on various exception cases.
> 
> 2.4.1 Overview of Throw Processing
> 
>  # Evaluate the thrown expression, and copy it into the buffer returned
>  by __cxa_allocate_exception, possibly using a copy constructor.  If
>  evaluation of the thrown expression exits by throwing an exception, that
>  exception will propagate instead of the expression itself.  Cleanup code
>  must ensure that __cxa_free_exception is called on the just allocated
>  exception object.  (If the copy constructor itself exits by throwing an
>  exception, terminate() is called.)
> 
> Does the last sentence mean that if there is a catch for what the copy
> constructor is throwing, it is ignored?

I think this is just the ABI document being out-of-date vs. the standard.
DR 475 jumped around a lot, but the final resolution (March 2010) makes
it clear that we are *not* supposed to call std::terminate if an exception
is thrown during the copy-initialization of an exception object.  We only
terminate if an exception is thrown after the initialization is complete,
e.g. by a destructor of that full-expression, by a cleanup during unwind,
or by the copy-initialization of a catch variable.

John.



More information about the cxx-abi-dev mailing list