From Bugzilla Helper: User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050513 Fedora/1.0.4-1.3.1 Firefox/1.0.4 Description of problem: If building an application that includes qxml.h you get several warnings: /usr/lib/qt-3.3/include/qxml.h:224: warning: 'class QXmlReader' has virtual functions but non-virtual destructor /usr/lib/qt-3.3/include/qxml.h:407: warning: 'class QXmlContentHandler' has virtual functions but non-virtual destructor /usr/lib/qt-3.3/include/qxml.h:424: warning: 'class QXmlErrorHandler' has virtual functions but non-virtual destructor /usr/lib/qt-3.3/include/qxml.h:433: warning: 'class QXmlDTDHandler' has virtual functions but non-virtual destructor /usr/lib/qt-3.3/include/qxml.h:441: warning: 'class QXmlEntityResolver' has virtual functions but non-virtual destructor /usr/lib/qt-3.3/include/qxml.h:448: warning: 'class QXmlLexicalHandler' has virtual functions but non-virtual destructor /usr/lib/qt-3.3/include/qxml.h:461: warning: 'class QXmlDeclHandler' has virtual functions but non-virtual destructor There are some other warnings that I saw: /usr/lib/qt-3.3/include/qnetworkprotocol.h:58: warning: 'class QNetworkProtocolFactoryBase' has virtual functions but non-virtual destructor /usr/lib/qt-3.3/include/qfiledialog.h:78: warning: 'class QFilePreview' has virtual functions but non-virtual destructor /usr/lib/qt-3.3/include/private/qucom_p.h:69: warning: 'struct QUBuffer' has virtual functions but non-virtual destructor /usr/lib/qt-3.3/include/private/qucom_p.h:77: warning: 'struct QUType' has virtual functions but non-virtual destructor /usr/lib/qt-3.3/include/private/qucom_p.h:104: warning: 'struct QUType_Null' has virtual functions but non-virtual destructor /usr/lib/qt-3.3/include/private/qucom_p.h:287: warning: 'struct QUType_enum' has virtual functions but non-virtual destructor /usr/lib/qt-3.3/include/private/qucom_p.h:307: warning: 'struct QUType_ptr' has virtual functions but non-virtual destructor /usr/lib/qt-3.3/include/private/qucom_p.h:326: warning: 'struct QUType_iface' has virtual functions but non-virtual destructor /usr/lib/qt-3.3/include/private/qucom_p.h:345: warning: 'struct QUType_idisp' has virtual functions but non-virtual destructor /usr/lib/qt-3.3/include/private/qucom_p.h:364: warning: 'struct QUType_bool' has virtual functions but non-virtual destructor /usr/lib/qt-3.3/include/private/qucom_p.h:383: warning: 'struct QUType_int' has virtual functions but non-virtual destructor /usr/lib/qt-3.3/include/private/qucom_p.h:403: warning: 'struct QUType_double' has virtual functions but non-virtual destructor /usr/lib/qt-3.3/include/private/qucom_p.h:423: warning: 'struct QUType_charstar' has virtual functions but non-virtual destructor /usr/lib/qt-3.3/include/private/qucom_p.h:444: warning: 'struct QUType_QString' has virtual functions but non-virtual destructor /usr/lib/qt-3.3/include/private/qucomextra_p.h:65: warning: 'struct QUType_QVariant' has virtual functions but non-virtual destructor /usr/lib/qt-3.3/include/private/qucomextra_p.h:87: warning: 'struct QUType_varptr' has virtual functions but non-virtual destructor This is pretty annoying especially in larger projects and fixing is easy. Version-Release number of selected component (if applicable): qt-devel-3.3.4-15.1 How reproducible: Always Steps to Reproduce: 1. Compile Qt application that includes on of the mentioned headers 2. Get coffee and bitch about annoying warnings Actual Results: Warnings. Expected Results: No warnings. Additional info:
this looks like a bug of gcc4 to me. I.e. QXmlReader is an interface (i.e. has only pure virtual functions), and QXmlErrorHandler is a subclass of QXmlDefaultHandler which surely has a virtual destructor.
It certainly matches the documentation: `-Wnon-virtual-dtor (C++ only)' Warn when a class appears to be polymorphic, thereby requiring a virtual destructor, yet it declares a non-virtual one. This warning is enabled by `-Wall'. A minimal testcase can be e.g.: struct C { virtual bool foo () = 0; }; struct D : public C { virtual bool foo () { return false; } virtual ~D (); }; Here, C is a class with virtual methods but without virtual destructor, so g++ warns.
Plus I think the warning is useful even for pure virtual classes. Otherwise: struct C { virtual void foo () = 0; #ifdef VIRTUAL_DTOR virtual #endif ~C (); }; C::~C () {} struct D : public C { virtual void foo () {} virtual ~D (); }; D::~D () {} C *p = (C *) new D (); int main () { delete p; } having different behaviour depending on whether C::~C() is virtual or not would went unnoticed.
Closed as "not a gcc bug" or "not a Qt bug"?