Boost logo

Boost :

Subject: Re: [boost] [exception] warning about non-virtual destructor - resolution?
From: Jeremiah Willcock (jewillco_at_[hidden])
Date: 2012-04-14 16:25:22


On Sat, 14 Apr 2012, Emil Dotchevski wrote:

> On Sat, Apr 14, 2012 at 6:00 AM, Mathias Gaunard <
> mathias.gaunard_at_[hidden]> wrote:
>
>> On 13/04/12 19:31, Jeffrey Lee Hellrung, Jr. wrote:
>>
>> I seem to remember this being discussed at length in the past...I believe
>>> this thread?
>>>
>>> http://boost.2283326.n4.**nabble.com/boost-exception-**
>>> detail-error-info-base-does-**not-have-virtual-destructor-**
>>> td3384903.html<http://boost.2283326.n4.nabble.com/boost-exception-detail-error-info-base-does-not-have-virtual-destructor-td3384903.html>
>>>
>>
>> Yes, basically, the author said he didn't care and it wasn't virtual by
>> design, and the compiler warning was bogus.
>>
>
> My personal opinion about this warning aside, I do want to suppress it. I
> simply can't reproduce it, and nobody has provided me with code that
> reproduces the problem. If you see the warning, grab the code and post it
> in the bug tracker.

On GCC 4.7.0, trying to compile libs/thread/future.cpp triggers a similar
warning for me with -Wall:

gcc.compile.c++ bin.v2/libs/thread/build/gcc-4.7.0/debug/link-static/threading-multi/future.o
In file included from ./boost/smart_ptr/shared_ptr.hpp:30:0,
                  from ./boost/shared_ptr.hpp:17,
                  from ./boost/date_time/time_clock.hpp:17,
                  from ./boost/thread/thread_time.hpp:9,
                  from ./boost/thread/future.hpp:14,
                  from libs/thread/src/future.cpp:6:
./boost/checked_delete.hpp: In instantiation of ¡void boost::checked_delete(T*) [with T = boost::error_info<boost::tag_original_exception_type, const std::type_info*>]¢:
./boost/smart_ptr/detail/shared_count.hpp:95:13: required from ¡boost::detail::shared_count::shared_count(Y*) [with Y = boost::error_info<boost::tag_original_exception_type, const std::type_info*>]¢
./boost/smart_ptr/shared_ptr.hpp:177:50: required from ¡boost::shared_ptr<T>::shared_ptr(Y*) [with Y = boost::error_info<boost::tag_original_exception_type, const std::type_info*>; T = boost::error_info<boost::tag_original_exception_type, const std::type_info*>]¢
./boost/exception/info.hpp:171:69: required from ¡const E& boost::exception_detail::set_info(const E&, const boost::error_info<Tag, T>&) [with E = boost::unknown_exception; Tag = boost::tag_original_exception_type; T = const std::type_info*]¢
./boost/exception/info.hpp:192:46: required from ¡typename boost::enable_if<boost::exception_detail::derives_boost_exception<E>, const E&>::type boost::operator<<(const E&, const boost::error_info<Tag, T>&) [with E = boost::unknown_exception; Tag = boost::tag_original_exception_type; T = const std::type_info*; typename boost::enable_if<boost::exception_detail::derives_boost_exception<E>, const E&>::type = const boost::unknown_exception&]¢
./boost/exception/detail/exception_ptr.hpp:182:13: required from ¡void boost::unknown_exception::add_original_type(const E&) [with E = std::exception]¢
./boost/exception/detail/exception_ptr.hpp:161:32: required from here
./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]

-- Jeremiah Willcock


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