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]

Checking exception specifications


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.


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