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 10:32:07 +0200
- References: <200008090812.EAA05467@venus>
Robert Dick wrote:
>
> That's not the warning to which I am referring.
Ok, that may be the reason why I didn't understand your last point.
> > I propose that gcc warn only if delete is invoked on a pointer to such a
> > class.
>
> Warnings exist to help developers avoid writing dangerous code. In
> general, a library developed with such a policy would be dangerous to use
> on a platform without the warning enabled.
I see it differently.
Either you develop a class hierarchy in a way that allows objects of derived
classes to be owned through a pointer to base class. Then you will have
library test code applying delete on a pointer to that base class; if you
forget to declare the dtor virtual, you get a warning. Fine.
Or your develop a class hierarchy where objects of derived classes are not
to be owned through a poiner to base class (this can be enforced by making
the base class destructor protected). Then there's no need for the base
class destructor to be virtual, and there shouldn't be a warning.