[Bug c++/16190] New: spurious warning about non-virtual destructor
ncm-nospam at cantrip dot org
gcc-bugzilla@gcc.gnu.org
Fri Jun 25 03:04:00 GMT 2004
The C++ compiler warns about correct code, under -Wall.
cat >bug.cc <<EOF
struct foo {
virtual void f() {}
~foo() {}
};
EOF
gcc -c -Wall bug.cc
bug.cc:1: warning: struct foo' has virtual functions but
non-virtual destructor
It is possible to write bad code that instantiates a "foo"
and deletes it polymorphically, but in common coding patterns
the instances may never be destroyed polymorphically -- always
created on the stack, or as a member of another object -- so
the warning is spurious. This warning should at least be moved
to "-Weffc++", if not removed entirely.
If it is considered too useful to remove entirely, it should be
applied only when a "foo" is actually created in a new-expression,
and thus actually could be deleted polymorphically.
--
Summary: spurious warning about non-virtual destructor
Product: gcc
Version: 3.4.1
Status: UNCONFIRMED
Severity: minor
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: ncm-nospam at cantrip dot org
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: any
GCC host triplet: any
GCC target triplet: any
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16190
More information about the Gcc-bugs
mailing list