Checking exception specifications

Sebastian Ritterbusch uabp@rz.uni-karlsruhe.de
Mon Aug 10 03:01:00 GMT 1998


Hi!

Is there any way to let the compiler check if the specifications are
correct? 

As an example if function A is only allowed to throw exception E1 but it
uses a function B that could throw E2 then this could be a problem. Either
the specification is incorrect or E2 should be handled in B.
(BTW If E2 is not handled in B the compiler should throw std::unexpected(); 
but in egcs-1.0.3 it doesn't. Also the new-operator in egcs seems not to throw 
std::badalloc in error but also terminates.)

It shouldn't be a problem for the compiler to check the specifications this
way, or do you know a tool that could do this? (It's a bit difficult to
check about 500 functions in my library for the correct specifications).

Stroustrup gives the advice to use a base class of all used exceptions as
the specification in all functions. I really don't like this idea. 

Ciao, Sebastian.



More information about the Gcc mailing list