[Bug c++/53596] g++-4.7 -Wall shouldn't complain for non-virtual protected dtor

kim.walisch at gmail dot com gcc-bugzilla@gcc.gnu.org
Thu Jun 7 08:28:00 GMT 2012


--- Comment #4 from kim.walisch at gmail dot com 2012-06-07 08:28:05 UTC ---
I found another post on the web
that explains the warning, it says:

"If Derived (see above) gets subclassed in the future, deletion in "main()"
will be undefined behavior. Ideally Derived should be marked "final" and then
there will also be no warning"

Based on this explanation I think the warning is valid. Clang's warning message
is somewhat more clear:

"warning: delete called on 'Derived' that has virtual functions but non-virtual
destructor [-Wdelete-non-virtual-dtor]"

This also explains why there is no warning in test2.cpp of my previous post.

More information about the Gcc-bugs mailing list