This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: throw ()
- To: aoliva at redhat dot com (Alexandre Oliva)
- Subject: Re: throw ()
- From: Mike Harrold <mharrold at cas dot org>
- Date: Wed, 30 Aug 2000 17:53:13 -0400 (EDT)
- Cc: gcc-bugs at gcc dot gnu dot org
Alexandre Oliva wrote:
>
> On Aug 30, 2000, Mike Harrold <mharrold@cas.org> wrote:
>
> > void foo() throw ();
>
> > indicates that foo() throws no exceptions.
>
> It actually indicates that, if any exceptions are thrown, the function
> unexpected() will be called, instead of having it propagated out by
> stack unwinding.
This would be the appropriate behaviour (it is unexpected, after all).
But is this what "throw ()" actually defines? or what it implies?
>
> > If that is the case, shouldn't the compiler warn about:
>
> > void foo() throw ()
> > {
> > throw "Oops!";
> > }
>
> I think warning in this case would be a good idea.
I agree.
Assuming "throw ()" defines no expcetions, I'd also like to see a
warning for the following scenario:
void foo() throw (std::bad_alloc&);
void bar() throw ()
{
foo();
}
Something like:
In function foo:
No try/catch block for function wth possible exceptions called from
function not throwing exceptions.
Or something with better wording.
This warning could (should?) not be on by default.
/Mike