Boost logo

Boost :

Subject: Re: [boost] [exception] warning about non-virtual destructor - resolution?
From: Daniel James (dnljms_at_[hidden])
Date: 2012-04-15 04:46:19

On 14 April 2012 22:30, Andrey Semashev <andrey.semashev_at_[hidden]> wrote:
> On Saturday 14 April 2012 22:13:36 Daniel James wrote:
>> 'checked_delete' is used by 'shared_ptr' and
>> is supposed to be safe for the case when the destructor isn't virtual,
>> so this might result in warnings for valid uses of 'shared_ptr'.
> My understanding is that checked_delete is intended to protect against freeing
> a pointer of an incomplete type, not against a missing virtual destructor. It
> is a tool of itself which can be used outside shared_ptr and in these cases a
> warning may be most appropriate. IMHO, if shared_ptr aims to support valid
> behavior in the lack of a virtual destructor, it should deal with the warnings
> itself.

I don't think shared_ptr can do that. There are two places where the
warning can be dealt with (the delete command and the deleted object),
neither of which are part of shared_ptr. Unless I've missed something
the only way it could deal with it without changing checked_delete is
to use its own implementation of checked_delete. If shared_ptr can't
use checked_delete then that suggests to me a real weakness in
checked_delete. The solution *might* be to add another function to
checked_delete that doesn't warn.

Incidentally this warning does come up for 'shared_ptr_test'.

Boost list run by bdawes at, gregod at, cpdaniel at, john at