Boost logo

Boost :

Subject: Re: [boost] Official warnings policy?
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2009-11-05 17:32:10


On Thu, Nov 5, 2009 at 1:50 PM, Kim Barrett <kab.conundrums_at_[hidden]> wrote:
>
> On Nov 5, 2009, at 2:04 PM, Emil Dotchevski wrote:
>>
>> - non-virtual-dtor on GCC contradicts a valid design choice.
>
> At least in recent versions of gcc, this warning is not generated when there
> is a non-public dtor.

This doesn't help much. If you make a base destructor protected, it
won't complain in the base class, but it will complain in the derived
class, which typically doesn't even define a destructor explicitly. It
isn't practical to silence that warning by limiting access to the
derived destructor because that destructor is safe to call as long as
the derived type isn't used as a base. And if it is designed to also
be used as a base, it should have a protected (or public virtual)
destructor.

> A public non-virtual dtor for a base class seems like
> a request for slicing bugs rather than a valid design choice.

There is a chance of slicing bugs, but the non-virtual destructor
means "no, you are not welcome to call the destructor through a base
pointer or reference." That is a design choice and I don't know of
another way to express it.

Emil Dotchevski
Reverge Studios, Inc.
http://www.revergestudios.com/reblog/index.php?n=ReCode


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk