Bug 13518 - "virtual functions but non-virtual destructor" warning incomplete
Summary: "virtual functions but non-virtual destructor" warning incomplete
Status: RESOLVED DUPLICATE of bug 11624
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.0
: P2 minor
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2003-12-30 12:40 UTC by Debian GCC Maintainers
Modified: 2004-01-03 13:33 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-12-30 18:04:09


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Debian GCC Maintainers 2003-12-30 12:40:31 UTC
[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.
Comment 1 Andrew Pinski 2003-12-30 18:04:09 UTC
Confirmed.  A better explation is that there is no warning if there is not a destructor there at all.
Comment 2 Andrew Pinski 2004-01-03 13:33:24 UTC
This is a dup of bug 11624.

*** This bug has been marked as a duplicate of 11624 ***