
On 18 April 2012 00:16, Vicente J. Botet Escriba <vicente.botet@wanadoo.fr> wrote:
demo.cpp:
#include<boost/checked_delete.hpp> #include<boost/exception_ptr.hpp>
Compiled with:
g++-mp-4.7 -c -Wall -I $BOOST_ROOT demo.cpp
That's the one. When testing, try explicitly using the '-Wdelete-non-virtual-dtor' flag. That way there will be an error if for versions of g++ that don't support it. This is a new feature and some distributions of gcc on windows are often a bit behind linux and mac. The following output if from trunk revision 78061: $ g++-mp-4.7 --version g++-mp-4.7 (GCC) 4.7.0 Copyright (C) 2012 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ g++-mp-4.7 -I $BOOST_ROOT demo.cpp -c -Wdelete-non-virtual-dtor In file included from demo.cpp:1:0: /Users/daniel/boost/git/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*>]': /Users/daniel/boost/git/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*>]' /Users/daniel/boost/git/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*>]' /Users/daniel/boost/git/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*]' /Users/daniel/boost/git/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&]' /Users/daniel/boost/git/boost/exception/detail/exception_ptr.hpp:182:13: required from 'void boost::unknown_exception::add_original_type(const E&) [with E = std::exception]' /Users/daniel/boost/git/boost/exception/detail/exception_ptr.hpp:161:32: required from here /Users/daniel/boost/git/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] $ clang-mp-3.1 --version clang version 3.1 (trunk 154872) Target: i386-apple-darwin9.8.0 Thread model: posix $ clang-mp-3.1 -I $BOOST_ROOT demo.cpp -c -Wdelete-non-virtual-dtor In file included from demo.cpp:1: /Users/daniel/boost/git/boost/checked_delete.hpp:34:5: warning: delete called on 'boost::error_info<boost::tag_original_exception_type, const std::type_info *>' that has virtual functions but non-virtual destructor [-Wdelete-non-virtual-dtor] delete x; ^ /Users/daniel/boost/git/boost/smart_ptr/detail/shared_count.hpp:95:13: note: in instantiation of function template specialization 'boost::checked_delete<boost::error_info<boost::tag_original_exception_type, const std::type_info *> >' requested here boost::checked_delete( p ); ^ /Users/daniel/boost/git/boost/smart_ptr/shared_ptr.hpp:177:44: note: in instantiation of function template specialization 'boost::detail::shared_count::shared_count<boost::error_info<boost::tag_original_exception_type, const std::type_info *> >' requested here explicit shared_ptr( Y * p ): px( p ), pn( p ) // Y must be complete ^ /Users/daniel/boost/git/boost/exception/info.hpp:170:42: note: in instantiation of function template specialization 'boost::shared_ptr<boost::error_info<boost::tag_original_exception_type, const std::type_info *>
::shared_ptr<boost::error_info<boost::tag_original_exception_type, const std::type_info *> >' requested here shared_ptr<error_info_tag_t> p( new error_info_tag_t(v) ); ^ /Users/daniel/boost/git/boost/exception/info.hpp:191:16: note: in instantiation of function template specialization 'boost::exception_detail::set_info<boost::unknown_exception, boost::tag_original_exception_type, const std::type_info *>' requested here return exception_detail::set_info(x,v); ^ /Users/daniel/boost/git/boost/exception/detail/exception_ptr.hpp:181:21: note: in instantiation of function template specialization 'boost::operator<<<boost::unknown_exception, boost::tag_original_exception_type, const std::type_info *>' requested here (*this) << original_exception_type(&typeid(e)); ^ /Users/daniel/boost/git/boost/exception/detail/exception_ptr.hpp:160:13: note: in instantiation of function template specialization 'boost::unknown_exception::add_original_type<std::exception>' requested here add_original_type(e); ^ 1 warning generated.