This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Proposal for improvement to C++ warnings


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-


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]