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: Joe Buck <jbuck at synopsys dot COM>
- To: aoliva at redhat dot com (Alexandre Oliva)
- Cc: jbuck at synopsys dot COM (Joe Buck), max at e-soft dot ru (Maxim Dementiev),gcc at gcc dot gnu dot org
- Date: Thu, 29 Nov 2001 11:15:25 -0800 (PST)
- Subject: Re: Using throw(): to use or not to use?
>
> On Nov 29, 2001, Joe Buck <jbuck@synopsys.COM> wrote:
>
> > Specififying throw() should, if anything, make it possible to generate
> > slightly faster code.
>
> Unless you're talking about the function marked as throw() itself,
> with an EH model such as setjmp(). This would require the function to
> set up handlers that would call unexpected() should the function throw
> or propagate some inappropriate exception.
Such handlers are only necessary if the function marked as throw() calls
some other function that is not marked as throw(), or operator new.
But yes, you're correct in that there can be a cost for setting up
this handler. However, for the case of the function itself throwing
there need be no overhead for the cases where these throws are not
reached, so it is only the propagation of exceptions from other calls
that is a cost.