This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Proposal for improvement to C++ warnings
- To: gcc at gcc dot gnu dot org
- Subject: Re: Proposal for improvement to C++ warnings
- From: Thomas Maeder <maeder at glue dot ch>
- Date: Wed, 09 Aug 2000 08:29:38 +0200
- References: <200008090436.AAA05293@venus>
Robert Dick wrote:
>
> Gcc 2.95 for C++ warns when a class inherits from a base class with a
> non-virtual destructor.
More exactly, it warns if a class has virtual member functions, but 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.
I propose that gcc warn only if delete is invoked on a pointer to such a
class.
> Private and protected inheritance from a base class with a non-virtual
> destructor do not introduce the danger motivating this warning.
Are you sure?