class A
{
public:
virtual ~A()
{
}
};
class B : virtual public A
{
public:
~B() throw()
{}
};
class C : public B
{
};
int main(int argc, char * argv [])
{
return 0;
}
That code gives the following error:
error: looser throw specifier for ‘virtual C::~C()’
error: overriding ‘virtual B::~B() throw ()’
on my debian testing ( gcc (Debian 4.6.0-10) 4.6.1 20110526 (prerelease) ) but compiles without errors on previous gcc versions ( 4.5 on my debian system again).
How does an exception specification affect virtual destructor overriding? According to that answer the compiler is supposed to create a default constructor matching the throw declaration of the base class. Obviously this is not what happens on new gcc. What has changed, what is the correct compiler behavior and is there some easy solution to the problem other than manually adding empty destructors in derived classes ( compiler flag for example).