Extension for a throw-like C++ qualifier

Mike Stump mrs@apple.com
Fri Mar 30 19:32:00 GMT 2007


On Mar 30, 2007, at 11:05 AM, Sergio Giro wrote:
> int TheClass::exceptMethod() _throw TheException {
>   throw TheException();
> }
>
> In this case, the gcc would check at runtime that the only exception
> the method exceptMethod may throw is TheException.

It does.

> Moreover
>
> int TheClass::wrongMethod() _throw () {
>   exceptMethod();
> }
>
> should yield an error,

It does, through, at runtime.

> should correct, since the exception is catched.

It is.

> I think that, if it is pessimistically supposed that every exception
> not enclosed into a try { } catch { } block may be thrown, the check
> can be done at runtime.

It is.

> The overall idea is, of course, to give information to the caller
> about the exceptions it must handle.

Right, exception specifications do.

> I think that this extension would worth the while. Any ideas?

?  Just what did you want that isn't in the standard again?  Is the  
feature you want just static checking for exception specifications at  
compile time?



More information about the Gcc mailing list