[Bug c++/22395] -Weffc++ shouldn't warn about non-virtual dtor of private subclasses
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Jan 5 17:13:00 GMT 2012
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
More information about the Gcc-bugs
mailing list