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]

Re: Proposal for improvement to C++ warnings


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?

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