Deallocators and Exceptions
Martin von Loewis
loewis at informatik.hu-berlin.de
Thu Aug 31 09:27:40 UTC 2000
> > 1. The C++ standard prohibits deallocators from throwing exceptions.
> > (I could not find such a requirement.)
There is no such requirement, but there should be one. This is Core
Issue 220
http://www.informatik.hu-berlin.de/~loewis/cwg_closed.html#220
As they point out, replacement functions must already have throw();
they don't see the need to require that for class deallocation
functions.
> > 2. Make the result undefined as what happens when a destructor throws
> > an exception. (See __cxa_new_vec ().)
In the light of that being consider ill-defined by some, making it
undefined seems like a good choice.
> (2) would be consistent with what we've specified for throws from the
> destructor. Any other observations?
I think that part of the spec must be revised. It currently says
# If the destructor throws an exception, the result is undefined.
This is in violation of 15.5.1, [except.terminate]/1
# In the following situations exception handling must be abandoned for
# less subtle error handling techniques: ...
# - when the destruction of an object during stack unwinding (15.2)
# exits using an exception, or
So I believe terminate must be called in this case.
Regards,
Martin
More information about the cxx-abi-dev
mailing list