This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: throw ()


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]