This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/3356: Multiple inheritance and throw()
- To: gcc-gnats at gcc dot gnu dot org
- Subject: c++/3356: Multiple inheritance and throw()
- From: markus at ibp dot de
- Date: Fri, 22 Jun 2001 11:06:29 +0200
>Number: 3356
>Category: c++
>Synopsis: Multiple inheritance from a class that has a throw() destructor doesn't compile
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: rejects-legal
>Submitter-Id: net
>Arrival-Date: Fri Jun 22 02:16:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:
>Release: 3.0
>Organization:
>Environment:
System: Linux kepler 2.2.14 #26 Tue Aug 1 15:33:53 CEST 2000 i686 unknown
Architecture: i686
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc-3.0/configure : (reconfigured) ../gcc-3.0/configure --enable-threads : (reconfigured) ../gcc-3.0/configure --enable-threads --enable-c99 : (reconfigured) ../gcc-3.0/configure --enable-threads
>Description:
It is not possible to compile a class that inherits from two classes,
one of which has a virtual destructor that is declared 'throw()'.
In the following example, the 'virtual' keyword is necessary. If one
declares 'throw()' destructor in class 'derived' the code compiles. If the
destructor has no 'throw()', it doesn't.
>How-To-Repeat:
The compilation of the file
-----------------------------------------------------------
class base
{
public:
~base(void) {}
};
class no_throw
{
public:
virtual ~no_throw(void) throw() {}
};
class derived : public no_throw, public base
{
};
-----------------------------------------------------------
results in the messages
-----------------------------------------------------------
cd ~/
make throw.o
g++ -c -o throw.o throw.C
throw.C:14: looser throw specifier for `virtual derived::~derived()'
throw.C:10: overriding `virtual no_throw::~no_throw() throw ()'
make: *** [throw.o] Error 1
Compilation exited abnormally with code 2 at Thu Jun 21 16:51:30
-----------------------------------------------------------
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: