This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Proposal for improvement to C++ warnings
- To: gcc at gcc dot gnu dot org
- Subject: Proposal for improvement to C++ warnings
- From: Robert Dick <dickrp at EE dot Princeton dot EDU>
- Date: Wed, 9 Aug 2000 00:36:32 -0400
Gcc 2.95 for C++ warns when a class inherits from a base class with a
non-virtual destructor. I propose that gcc warn only when a class publicly
inherits from a base class with a public non-virtual destructor.
The warning exists to prevent the deletion of a child class through a pointer
to a parent with a non-virtual destructor. This results in undefined
behavior, according to The Standard. However, there are a number of safe and
useful practices which are unnecessarily warned against because the warning
rule is too broad, thereby encouraging developers to disable the warning.
Private and protected inheritance from a base class with a non-virtual
destructor do not introduce the danger motivating this warning. However, they
are warned against, anyway. The same is true private, protected, and public
inheritance from a base class with a protected non-virtual destructor.
-Robert Dick-