This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Troubles with exception specification
- To: egcs-bugs at cygnus dot com, egcs at cygnus dot com
- Subject: Troubles with exception specification
- From: Ryszard Kabatek <rysio at rumcajs dot chemie dot uni-halle dot de>
- Date: Tue, 22 Sep 1998 11:06:18 +0200 (CEST)
- Reply-To: kabatek at chemie dot uni-halle dot de
There are 2 problems with the exception specification in egcs-1.1.
1. In the sample below, the virtual function D::func,
that overrides the virtual function B::func,
has a less restrictive exception specification.
However the compiler does compile the sample without any warning!
2. The call of B::func should throw `bad_exception', but it doesn't!
On Linux (RedHat 5.1, PC) it causes:
Aborted (core dumped),
on Linux (S.u.S.E. 5.1, PC, libc 5)
IOT trap/Abort.
//////////
// main.cc
//////////
# include <iostream.h>
# include <stdexcept>
class B {
public:
virtual ~B() throw() {}
virtual void func() throw(logic_error, bad_exception)
{throw runtime_error("XXL");}
};
class D : public B {
public:
virtual void func() {}
};
int main()
{
try {
B b;
b.func();
}
catch (exception& exc) {
cerr << exc.what() << '\n';
}
}
Ryszard Kabatek
---
Martin-Luther University Halle-Wittenberg
Department of Physical Chemistry
Geusaer Str. 88, 06217 Merseburg, Germany
Tel. +49 3461 46 2487 Fax. +49 3461 46 2129