This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/22395] -Weffc++ shouldn't warn about non-virtual dtor of private subclasses
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 05 Jan 2012 17:13:02 +0000
- Subject: [Bug c++/22395] -Weffc++ shouldn't warn about non-virtual dtor of private subclasses
- Auto-submitted: auto-generated
- References: <bug-22395-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22395
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-01-05 17:13:02 UTC ---
private inheritance doesn't mean the destructor can't be called with the wrong
static type
class Foo {
public:
~Foo() {}
virtual void f() { }
};
class Bar : private Foo {
public:
Foo* get() { return this; }
};
int main()
{
Bar* b = new Bar;
delete b->get();
}
as stated in PR 16166 comment 3, the 3rd edition of Effective C++ changes the
guideline, and -Wdelete-non-virtual-dtor is usually a better option anyway