This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor
- From: "cesarb at cesarb dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 21 Aug 2007 10:54:25 -0000
- Subject: [Bug c++/7302] -Wnon-virtual-dtor should't complain of protected dtor
- References: <bug-7302-1037@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #25 from cesarb at cesarb dot net 2007-08-21 10:54 -------
The testcase seems to be missing one case where it should warn:
class H
{
protected:
~H();
public:
virtual void deleteme() = 0;
};
H::~H()
{
}
void
H::deleteme()
{
delete this;
}
class I : public H
{
protected:
~I();
public:
virtual void deleteme() { H::deleteme(); }
void oops();
};
I::~I()
{
}
void
I::oops()
{
deleteme();
}
Here, H must have a virtual destructor. The point where it can know it should
warn is the "delete this;" line.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7302