This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/11624] New: -Wnon-virtual-dtor doesn't always work
- From: "bangerth at dealii dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 21 Jul 2003 21:10:13 -0000
- Subject: [Bug c++/11624] New: -Wnon-virtual-dtor doesn't always work
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11624
Summary: -Wnon-virtual-dtor doesn't always work
Product: gcc
Version: 3.4
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: bangerth at dealii dot org
CC: gcc-bugs at gcc dot gnu dot org,gdr at gcc dot gnu dot
org
I just closed a PR that had essentially this code:
------------------------------------
struct A
{
virtual void afunc () {};
};
struct B
{
virtual void bfunc () {};
};
struct C : A, B
{};
int main (void)
{
B * Bptr = new C();
delete Bptr;
}
----------------------------
What was wrong with that PR is immaterial here, but one of the things
is that the submitter didn't recognize that he should have a virtual
destructor. That's what we have -Wnon-virtual-dtor for, I thought, since
it says:
-----------------------------------
@item -Wnon-virtual-dtor @r{(C++ only)}
@opindex Wnon-virtual-dtor
Warn when a class appears to be polymorphic, thereby requiring a virtual
destructor, yet it declares a non-virtual one.
This warning is enabled by @option{-Wall}.
-----------------------------------
Alas, this option doesn't trigger on above code, for no version after 3.2.
(I don't have an older version on my present system, so can't check.) I
think it should, though, shouldn't it?
W.