If compiled with -Wall, g++-4.0.1 will warn on classes with virtual functions but *no* destructor at all. Note that even though this warning is well justified on classes implementing a destructor - because virtual classes might get deleted thru a base class pointer - this warning is not useful for classes with a trivial (compiler-generated) destructor. Note that g++-3.4 and earler releases of g++ did not warn on this case either.
How to reproduce: Enter the following code and save as "destructor.cpp": /*snip*/ class A { int x; public: A(int a) : x(a) { } // virtual int get(void) const { return x; } }; class B : public A { int y; public: B(int a) : A(a), y(a+1) { } // virtual int get(void) const { return y; } }; int main(int argc,char **argv) { return 0; } /*snip*/ Then compile as: $ g++-4.0 -Wall destructor.cpp Compiler output is: destructor.cpp:1: warning: 'class A' has virtual functions but non-virtual destructor destructor.cpp:14: warning: 'class B' has virtual functions but non-virtual destructor Note that this warning is unjustified because deleting a class thru a base class pointer works fine if both derived and base class only provide a trivial (compiler-generated) destructor. -- Summary: void warning on virtual classes with no destructor Product: gcc Version: 4.0.1 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: thor at math dot tu-berlin dot de CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23140