This is the mail archive of the
mailing list for the GCC project.
Re: Handling of exception specification violations
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: Peter Schuller <peter dot schuller at infidyne dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Sun, 23 Oct 2005 15:07:09 +0100
- Subject: Re: Handling of exception specification violations
- References: <20051021145429.GA66063@starfury.scode.org>
Peter Schuller wrote:
In C++, I would like to take advantage of throw() clauses for their
documentative value (and possible future value if gcc implements
checked exceptions). At the same time however, I want to *usefully*
handle the throwing of unexpected exceptions (where "useful" includes
being able to inspect the exception in question).
Toward this end I have a couple of questions that my Googling has not
* gcc has an option -fno-enforce-eh-specs which has pretty much the effect
I would want because it allows for generic top-level catch() statements
that exit with a useful error message. The man-page says the compiler
"will still optimize based on the exception specifications". Should I
interpret this as saying it is *unsafe* to enable this option with
code that *does* throw unexpected exceptions? If not, is it guaranteed
to *be* safe?
the code will be unsafe. If an exception is thrown out of a throw () function,
the effects will be undefined.
* providing user-defined behavior for std::unexpected() (as exemplified
at ) would be an alternative aswell - *if* I can obtain a reference
to the exception during runtime. Is there some way (standard or
gcc-specific) to do this?
This is target specific. Note that the exception object might be foreign (a non
C++ object). Look at unwind.h for details.
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
firstname.lastname@example.org :: http://www.planetfall.pwp.blueyonder.co.uk