Boost logo

Boost :

Subject: Re: [boost] [exception] warning about non-virtual destructor - resolution?
From: Daniel James (dnljms_at_[hidden])
Date: 2012-04-14 17:13:36


2012/4/14 Jeremiah Willcock <jewillco_at_[hidden]>:
> ./boost/checked_delete.hpp:34:5: warning: deleting object of polymorphic
> class type ‘boost::error_info<boost::tag_original_exception_type, const
> std::type_info*>’ which has non-virtual destructor might cause undefined
> behaviour [-Wdelete-non-virtual-dtor]

That's a new warning for g++ 4.7, so unfortunately it doesn't explain
the original bug report. It would be useful to have a demonstration of
that as well. Anyone have any ideas?

In this case the warning fires because it's triggered by the delete
command, which is not covered by the system header pragma in the
exception headers. This is different to the old warning which was
triggered by the destructor. This might actually be a problem for
other libraries as well. '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'. So,
for g++ 4.7 and up, the correct solution *might* be to use the new
pragmas to disable the warning in checked_delete. But it might not,
I'm not familiar enough with checked_delete to know if that would be
appropriate.


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