[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#212260: g++-3.3: "virtual functions but non-virtual destructor" warning incomplete



Package: g++-3.3
Version: 1:3.3.2-0pre4
Severity: wishlist

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.

-- System Information:
Debian Release: testing/unstable
Architecture: i386
Kernel: Linux zewt.org 2.4.20 #1 Fri Feb 14 20:45:48 EST 2003 i686
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8

Versions of packages g++-3.3 depends on:
ii  gcc-3.3                    1:3.3.2-0pre3 The GNU C compiler
ii  gcc-3.3-base               1:3.3.2-0pre3 The GNU Compiler Collection (base 
ii  libc6                      2.3.2-7       GNU C Library: Shared libraries an
ii  libstdc++5-3.3-dev         1:3.3.2-0pre3 The GNU Standard C++ Library v3 (d

-- no debconf information




Reply to: