Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 162150 - Compiling app that uses QXml throws warnings
Summary: Compiling app that uses QXml throws warnings
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc
Version: 4
Hardware: i386
OS: Linux
medium
low
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2005-06-30 11:57 UTC by Tim Niemueller
Modified: 2007-11-30 22:11 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2005-08-25 22:44:18 UTC


Attachments (Terms of Use)

Description Tim Niemueller 2005-06-30 11:57:24 UTC
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:

Comment 1 Ngo Than 2005-08-02 13:15:17 UTC
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.

Comment 2 Jakub Jelinek 2005-08-19 10:50:11 UTC
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.

Comment 3 Jakub Jelinek 2005-08-25 22:44:18 UTC
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.

Comment 4 Tim Niemueller 2006-01-13 10:16:37 UTC
Closed as "not a gcc bug" or "not a Qt bug"?


Note You need to log in before you can comment on or make changes to this bug.