This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Checking exception specifications
- To: egcs at cygnus dot com
- Subject: Checking exception specifications
- From: Sebastian Ritterbusch <uabp at rz dot uni-karlsruhe dot de>
- Date: Mon, 10 Aug 1998 12:00:51 +0200 (CES)
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.