|
Boost : |
Subject: Re: [boost] [exception] warning about non-virtual destructor - resolution?
From: Hite, Christopher (Christopher.Hite_at_[hidden])
Date: 2012-04-16 08:47:56
From: Of Olaf van der Spek
> On Sun, Apr 15, 2012 at 10:54 AM, Andrey Semashev <andrey.semashev_at_[hidden]> wrote:
> > Using a separate implementation of checked_delete in shared_ptr is
> > what I had in mind. And this implementation should not be public, I think.
> Isn't the type guaranteed to be complete when shared_ptr calls delete?
No. Let's take Z derived from Y derived from X. All three have non-virtual deconstructor:
shared_ptr<Y>(new Y); // safe since
shared_ptr<X>(new Y); // safe since type Y is passed eventually to checked_delete
shared_ptr<X>(static_cast<Y*>( new Z )); // no way it's safe - calls only ~Y()
Seriously the guy could just put in a "virtual ". It costs almost nothing and would be way less painful then a bunch of compiler specific warning supression. Heaping things is way more expensive than a virtual call.
My vote is for A) adding "virtual". If for some reason he's got a problem with it he can do B) define error_info final so gcc shuts up. There's a reason they added it to the standard.
I would care if this were in some cpp, but it's in a header included indirectly by serveral of my compilation scopes.
Actually I don't care as much about this as my issues with mpl/fusion, but it just seems trivial to fix.
Chris
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk