This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Using throw(): to use or not to use?
- From: fche at redhat dot com (Frank Ch. Eigler)
- To: Joe Buck <jbuck at synopsys dot COM>
- Cc: max at e-soft dot ru (Maxim Dementiev), gcc at gcc dot gnu dot org
- Date: 29 Nov 2001 15:57:35 -0500
- Subject: Re: Using throw(): to use or not to use?
- References: <200111291735.JAA05491@atrus.synopsys.com>
Joe Buck <jbuck@synopsys.COM> writes:
: [...] Specififying throw() should, if anything, make it possible to
: generate slightly faster code. If the code is instead slower, I'd
: call it a bug, [...]
Not really. Within the body of a function declared with throw(), the
compiler must normally emit *extra* code that asserts that there are
no exceptions thrown from it, sort of like this:
try { BODY } catch (...) { abort(); }
The *caller* of such a function may in turn assume that no exceptions
can come back out, so the compiler may (eventually?) optimize based on
that. So, specifying throw() allows new optimization opportunities
only at the caller.
- FChE