This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/13518] New: "virtual functions but non-virtual destructor" warning incomplete
- From: "debian-gcc at lists dot debian dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 30 Dec 2003 12:40:35 -0000
- Subject: [Bug c++/13518] New: "virtual functions but non-virtual destructor" warning incomplete
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
[forwarded from http://bugs.debian.org/212260]
This code:
#include <stdio.h>
struct foo {
~foo() { }
virtual void bar() { }
};
struct fum: public foo {
virtual ~fum() { printf("x\n"); }
};
main() { foo *x = new fum; delete x; }
generates:
blah.cc:2: warning: `struct foo' has virtual functions but non-virtual
destructor
and "x" is not output. (This is expected.)
Comment out the ~foo dtor. The code is still incorrect ("x" is still
not output), but no warning is reported. As the default dtor is
non-virtual, this warning should also be output if an object has virtual
functions but no destructor at all.
--
Summary: "virtual functions but non-virtual destructor" warning
incomplete
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: debian-gcc at lists dot debian dot org
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13518