missing warning

Alexander V. Lukyanov lav@long.yar.ru
Sun Nov 22 05:47:00 GMT 1998


Hi!

In the following C++ program the ~B destructor is not called (egcs-1.1). I
know why, but none the less I beleave a warning is required.

Something like "class B has virtual destructor, but parent class A does not"
on pointer conversion, or on declaration of B if class A has virtual functions.

#include <stream.h>
class A
{
public:
   virtual void func() = 0;
};
class B : public A
{
public:
   void func() {};
   virtual ~B() { cout << "~B\n"; }
};
int main()
{
   A *a=new B();
   delete a;
   return 0;
}

   Alexander.



More information about the Gcc-bugs mailing list