This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/13518] New: "virtual functions but non-virtual destructor" warning incomplete


[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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]