This is the mail archive of the gcc@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]
Other format: [Raw text]

Re: Inclusion in an official release of a new throw-like qualifier


Sergio Giro wrote:
   I started a thread about the possible development of a throw-like
qualifier for C++ which may statically check that the only possible
exceptions are those declared in the qualifier (please see the
corresponding thread:

I'm strongly opposed to adding a new qualifier with slightly different semantics from one already in the language. I agree with Mike that the right answer is to implement stricter checking of standard exception specifications.


Furthermore, gcc internals currently don't support much in the way of inter-procedural analysis, and none between routines in separate modules. So if your function calls another function, we don't know what it can throw (unless the called function also has an exception specification). If you want more than single-function analysis, you're probably better off with an external tool, at least for now.

Sergio Giro wrote (in reply to Mike Stump):
> is ideal, but it seems to me not practical at all. Every stuff using
> the throw qualifier as specified in the standards will not work. If an
> inline method in a standard header is
>   theInlineMethod (void) throw () { throw theException(); };
> this will not even compile...

I doubt that anything like this appears in the standard headers.

> In addition, the semantic meaning is not the same: a
> throw (a,b,c)  qualifier indicates that you are able only to catch the
> exceptions a, b and c, and that every other exception will be seen as
> std::unexpected. Nevertheless, a
> _throw(a,b,c) qualifier should indicate that the only exceptions that
> can arise are a, b and c.

But in both cases, the only exceptions that can leave the function are a, b and c. I don't see what your extension would add that wouldn't also be provided by -Wexception-specs.

Jason


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