public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Ideas for compile-time checking of exception specifications.
@ 2005-10-12 23:16 Kevin Regan
  0 siblings, 0 replies; only message in thread
From: Kevin Regan @ 2005-10-12 23:16 UTC (permalink / raw)
  To: gcc

There seem to be some arguments floating around about why it may not be a 
good idea to implement compile time checking of exception specifications.  
However, I'm not sure that I agree with these arguments.

I think the purveyors of these arguments have the point of view that any 
such feature would have to be a compile-time error generation feature, 
which, like Java, would do an exhaustive search of all exception 
information.  What I would like to see is a feature that generates warnings 
to the user  and only operates on those functions/methods that participate 
in the exception specification mechanism.

The key thing to realize is that a function that does not specify an 
exception specification can be safely ignored -- this makes us no worse off 
than we currently are.  The warnings generated by the compiler could focus 
exclusively on those functions that do have exception specifications.  This 
narrows the field and allows for a fairly simply system by which a user can 
receive a great deal of useful information about functions that participate 
in the exception specification mechanism.

Another common argument is that there may be code that looks like it would 
violate the exception specification, but through further analysis of the 
code, actually would not.  A very simple example of this would be:

void bar() { throw MyException(); }
void foo() throw(MyException) {
    bar();
    throw AnotherException();
}

My answer: who cares?  Many other warnings in the compiler have the same 
issue.  In addition, as a developer, I would want to know about the 
possibility of an exception specification violation (especially if the 
function body of bar() was changed to not throw a MyException()).

So, to some up, I think that a very useful exception specification warning 
feature could be added to the compiler that would catch the majority of 
programming errors that the developer would be interested in.  Also, given 
that we would only be examining functions that had exception specifications 
in their signature, it would be a fairly straightforward feature to 
implement.

Sincerely,
Kevin Regan

_________________________________________________________________
DonÂ’t just search. Find. Check out the new MSN Search! 
http://search.msn.click-url.com/go/onm00200636ave/direct/01/

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-10-12 22:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-12 23:16 Ideas for compile-time checking of exception specifications Kevin Regan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).