From 50899b8f1b1888450b3753b6dba79a774432aeaf Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Wed, 5 Jul 2017 16:27:16 -0700 Subject: [PATCH 01/10] added bug_11874_test.cpp --- test/Jamfile.v2 | 2 ++ test/bug_11874_test.cpp | 10 ++++++++++ 2 files changed, 12 insertions(+) create mode 100644 test/bug_11874_test.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index df85359..2b4cad8 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -71,3 +71,5 @@ compile errinfo_file_name_hpp_test.cpp ; compile errinfo_file_open_mode_hpp_test.cpp ; compile errinfo_nested_exception_hpp_test.cpp ; compile errinfo_type_info_name_hpp_test.cpp ; + +compile bug_11874_test.cpp ; diff --git a/test/bug_11874_test.cpp b/test/bug_11874_test.cpp new file mode 100644 index 0000000..3d8fd4a --- /dev/null +++ b/test/bug_11874_test.cpp @@ -0,0 +1,10 @@ +//Copyright (c) 2006-2017 Emil Dotchevski and Reverge Studios, Inc. + +//Distributed under the Boost Software License, Version 1.0. (See accompanying +//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#include + +int main() +{ +} From 2a2557b903af0ac3a0e7d5dc989d43e43216f8f5 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sat, 7 Apr 2018 14:58:25 +0100 Subject: [PATCH 02/10] Fully qualify error_info_base for Visual C++ 7.1 Test are failing on Visual C++ 7.1, I think because it's not importing error_info_base into the class' namespace, so hopefully this will fix it. I don't have access to the compiler, so I'm not sure. --- include/boost/exception/detail/error_info_impl.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/exception/detail/error_info_impl.hpp b/include/boost/exception/detail/error_info_impl.hpp index 6c48d61..902214a 100644 --- a/include/boost/exception/detail/error_info_impl.hpp +++ b/include/boost/exception/detail/error_info_impl.hpp @@ -46,7 +46,7 @@ boost error_info: public exception_detail::error_info_base { - error_info_base * + exception_detail::error_info_base * clone() const { return new error_info(*this); From de6cef966b5c788774aac16d42eeee0fc2ad9565 Mon Sep 17 00:00:00 2001 From: Glen Fernandes Date: Mon, 17 Sep 2018 07:32:49 -0400 Subject: [PATCH 03/10] Fix unit tests that did not return report_errors() --- test/error_info_basic_test.cpp | 4 ++-- test/no_exceptions_test.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/error_info_basic_test.cpp b/test/error_info_basic_test.cpp index aa8d6a7..488360d 100644 --- a/test/error_info_basic_test.cpp +++ b/test/error_info_basic_test.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include @@ -25,5 +25,5 @@ main() { BOOST_TEST(boost::get_error_info(e) && !strcmp(boost::get_error_info(e)->c_str(),"doh")); } - return 0; + return boost::report_errors(); } diff --git a/test/no_exceptions_test.cpp b/test/no_exceptions_test.cpp index 2609be6..d335fb6 100644 --- a/test/no_exceptions_test.cpp +++ b/test/no_exceptions_test.cpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include struct @@ -39,7 +39,7 @@ boost #ifndef BOOST_NO_RTTI BOOST_TEST(s.find("my_tag")!=std::string::npos); #endif - exit(0); + exit(boost::report_errors()); } } From e3590d89af6ebd99d8900d778921c96e40b3388f Mon Sep 17 00:00:00 2001 From: Mike Dev Date: Tue, 2 Oct 2018 21:33:32 +0200 Subject: [PATCH 04/10] [CMake] Add minimal cmake file Generate cmake target that builds the library and which can be used by other libraries to express their dependency on this library and retrieve any configuration information such as the include directory, binary to link to, transitive dependencies, necessary compiler options or the required c++ standards level. --- CMakeLists.txt | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..29d8424 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,27 @@ +# Copyright 2018 Mike Dev +# Distributed under the Boost Software License, Version 1.0. +# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt +# +# NOTE: CMake support for Boost.Exception is currently experimental at best +# and the interface is likely to change in the future + +cmake_minimum_required(VERSION 3.5) +project(BoostException LANGUAGES CXX) + + +add_library(boost_exception src/clone_current_exception_non_intrusive.cpp) +add_library(Boost::exception ALIAS boost_exception) + +target_include_directories(boost_exception PUBLIC include) + +target_link_libraries(boost_exception + PUBLIC + Boost::assert + Boost::config + Boost::core + Boost::smart_ptr + Boost::throw_exception + Boost::tuple + Boost::type_traits +) + From 386f5507cb8ec99c03ca535bea4f8bd61e0de910 Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Tue, 15 Jan 2019 23:55:37 +0300 Subject: [PATCH 05/10] extract exception type name from std::exception_ptr on libstdc++ --- include/boost/exception/diagnostic_information.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/boost/exception/diagnostic_information.hpp b/include/boost/exception/diagnostic_information.hpp index 48f06a0..f5033b7 100644 --- a/include/boost/exception/diagnostic_information.hpp +++ b/include/boost/exception/diagnostic_information.hpp @@ -45,6 +45,10 @@ boost std::exception const * se=current_exception_cast(); if( be || se ) return exception_detail::diagnostic_information_impl(be,se,true,verbose); +#if defined(__GLIBCXX__) && __cplusplus >= 201103L && !defined(BOOST_NO_RTTI) + else if (auto* p=std::current_exception().__cxa_exception_type()) + return "Dynamic exception type: "+boost::core::demangle(p->name()); +#endif else return "No diagnostic information available."; } From 607268dd8e398d3cd04e8622dd087bf963e56183 Mon Sep 17 00:00:00 2001 From: Juha Date: Mon, 28 Jan 2019 09:48:53 +0200 Subject: [PATCH 06/10] Replaced throw() with BOOST_NOEXCEPT_OR_NOTHROW With throw(), Visual Studio 2017 emitted a warning "C26439 SPECIAL_NOEXCEPT". Reproducible at least if code analysis was set to level: "Microsoft Native Recommended Rules". https://docs.microsoft.com/en-us/visualstudio/code-quality/c26439?view=vs-2017 --- example/example_io.cpp | 4 ++-- include/boost/exception/detail/error_info_impl.hpp | 4 ++-- include/boost/exception/detail/exception_ptr.hpp | 8 ++++---- include/boost/exception/diagnostic_information.hpp | 2 +- include/boost/exception/info.hpp | 2 +- src/clone_current_exception_non_intrusive.cpp | 2 +- test/cloning_test.cpp | 2 +- test/copy_exception_test.cpp | 2 +- test/diagnostic_information_test.cpp | 6 +++--- test/exception_ptr_test.cpp | 2 +- test/helper2.cpp | 6 +++--- test/helper2.hpp | 6 +++--- test/no_exceptions_test.cpp | 2 +- 13 files changed, 24 insertions(+), 24 deletions(-) diff --git a/example/example_io.cpp b/example/example_io.cpp index 09b6138..f489332 100644 --- a/example/example_io.cpp +++ b/example/example_io.cpp @@ -35,14 +35,14 @@ error: //Base for all exception objects we throw. public: char const * - what() const throw() + what() const BOOST_NOEXCEPT_OR_NOTHROW { return "example_io error"; } protected: - ~error() throw() + ~error() BOOST_NOEXCEPT_OR_NOTHROW { } }; diff --git a/include/boost/exception/detail/error_info_impl.hpp b/include/boost/exception/detail/error_info_impl.hpp index 6c48d61..cf28fd1 100644 --- a/include/boost/exception/detail/error_info_impl.hpp +++ b/include/boost/exception/detail/error_info_impl.hpp @@ -35,7 +35,7 @@ boost virtual error_info_base * clone() const = 0; virtual - ~error_info_base() throw() + ~error_info_base() BOOST_NOEXCEPT_OR_NOTHROW { } }; @@ -73,7 +73,7 @@ boost } #endif #endif - ~error_info() throw() + ~error_info() BOOST_NOEXCEPT_OR_NOTHROW { } value_type const & diff --git a/include/boost/exception/detail/exception_ptr.hpp b/include/boost/exception/detail/exception_ptr.hpp index 8e19f0d..a7f0a25 100644 --- a/include/boost/exception/detail/exception_ptr.hpp +++ b/include/boost/exception/detail/exception_ptr.hpp @@ -105,7 +105,7 @@ boost boost::exception, std::bad_alloc { - ~bad_alloc_() throw() { } + ~bad_alloc_() BOOST_NOEXCEPT_OR_NOTHROW { } }; struct @@ -113,7 +113,7 @@ boost boost::exception, std::bad_exception { - ~bad_exception_() throw() { } + ~bad_exception_() BOOST_NOEXCEPT_OR_NOTHROW { } }; template @@ -174,7 +174,7 @@ boost add_original_type(e); } - ~unknown_exception() throw() + ~unknown_exception() BOOST_NOEXCEPT_OR_NOTHROW { } @@ -220,7 +220,7 @@ boost add_original_type(e1); } - ~current_exception_std_exception_wrapper() throw() + ~current_exception_std_exception_wrapper() BOOST_NOEXCEPT_OR_NOTHROW { } diff --git a/include/boost/exception/diagnostic_information.hpp b/include/boost/exception/diagnostic_information.hpp index 48f06a0..60d74b8 100644 --- a/include/boost/exception/diagnostic_information.hpp +++ b/include/boost/exception/diagnostic_information.hpp @@ -175,7 +175,7 @@ boost inline char const * - diagnostic_information_what( exception const & e, bool verbose=true ) throw() + diagnostic_information_what( exception const & e, bool verbose=true ) BOOST_NOEXCEPT_OR_NOTHROW { char const * w=0; #ifndef BOOST_NO_EXCEPTIONS diff --git a/include/boost/exception/info.hpp b/include/boost/exception/info.hpp index f7ac50e..5e3ad52 100644 --- a/include/boost/exception/info.hpp +++ b/include/boost/exception/info.hpp @@ -62,7 +62,7 @@ boost { } - ~error_info_container_impl() throw() + ~error_info_container_impl() BOOST_NOEXCEPT_OR_NOTHROW { } diff --git a/src/clone_current_exception_non_intrusive.cpp b/src/clone_current_exception_non_intrusive.cpp index 7ebd7b5..932bca8 100644 --- a/src/clone_current_exception_non_intrusive.cpp +++ b/src/clone_current_exception_non_intrusive.cpp @@ -230,7 +230,7 @@ namespace { } - ~cloned_exception() throw() + ~cloned_exception() BOOST_NOEXCEPT_OR_NOTHROW { } diff --git a/test/cloning_test.cpp b/test/cloning_test.cpp index c5a4ae9..138a38c 100644 --- a/test/cloning_test.cpp +++ b/test/cloning_test.cpp @@ -73,7 +73,7 @@ derives_std_boost_exception: { } - char const * what() const throw() + char const * what() const BOOST_NOEXCEPT_OR_NOTHROW { return wh_; } diff --git a/test/copy_exception_test.cpp b/test/copy_exception_test.cpp index a88e6d5..69acb65 100644 --- a/test/copy_exception_test.cpp +++ b/test/copy_exception_test.cpp @@ -29,7 +29,7 @@ err: } virtual - ~err() throw() + ~err() BOOST_NOEXCEPT_OR_NOTHROW { --exc_count; } diff --git a/test/diagnostic_information_test.cpp b/test/diagnostic_information_test.cpp index 05ec554..35eb5e8 100644 --- a/test/diagnostic_information_test.cpp +++ b/test/diagnostic_information_test.cpp @@ -28,7 +28,7 @@ error1: boost::exception { char const * - what() const throw() + what() const BOOST_NOEXCEPT_OR_NOTHROW { return "error1"; } @@ -45,7 +45,7 @@ error3: std::exception { char const * - what() const throw() + what() const BOOST_NOEXCEPT_OR_NOTHROW { return "error3"; } @@ -57,7 +57,7 @@ error4: boost::exception { char const * - what() const throw() + what() const BOOST_NOEXCEPT_OR_NOTHROW { return diagnostic_information_what(*this); } diff --git a/test/exception_ptr_test.cpp b/test/exception_ptr_test.cpp index 367558c..ebcb1d5 100644 --- a/test/exception_ptr_test.cpp +++ b/test/exception_ptr_test.cpp @@ -87,7 +87,7 @@ exc: } virtual - ~exc() throw() + ~exc() BOOST_NOEXCEPT_OR_NOTHROW { --exc_count; } diff --git a/test/helper2.cpp b/test/helper2.cpp index 982d084..88809a7 100644 --- a/test/helper2.cpp +++ b/test/helper2.cpp @@ -20,7 +20,7 @@ boost } derives_boost_exception:: - ~derives_boost_exception() throw() + ~derives_boost_exception() BOOST_NOEXCEPT_OR_NOTHROW { } @@ -32,7 +32,7 @@ boost } derives_boost_exception_virtually:: - ~derives_boost_exception_virtually() throw() + ~derives_boost_exception_virtually() BOOST_NOEXCEPT_OR_NOTHROW { } @@ -44,7 +44,7 @@ boost } derives_std_exception:: - ~derives_std_exception() throw() + ~derives_std_exception() BOOST_NOEXCEPT_OR_NOTHROW { } diff --git a/test/helper2.hpp b/test/helper2.hpp index 0708476..885eee5 100644 --- a/test/helper2.hpp +++ b/test/helper2.hpp @@ -21,7 +21,7 @@ boost public std::exception { explicit derives_boost_exception( int x ); - virtual ~derives_boost_exception() throw(); + virtual ~derives_boost_exception() BOOST_NOEXCEPT_OR_NOTHROW; int x_; }; @@ -31,7 +31,7 @@ boost public std::exception { explicit derives_boost_exception_virtually( int x ); - virtual ~derives_boost_exception_virtually() throw(); + virtual ~derives_boost_exception_virtually() BOOST_NOEXCEPT_OR_NOTHROW; int x_; }; @@ -40,7 +40,7 @@ boost public std::exception { explicit derives_std_exception( int x ); - virtual ~derives_std_exception() throw(); + virtual ~derives_std_exception() BOOST_NOEXCEPT_OR_NOTHROW; int x_; }; diff --git a/test/no_exceptions_test.cpp b/test/no_exceptions_test.cpp index d335fb6..2e8665a 100644 --- a/test/no_exceptions_test.cpp +++ b/test/no_exceptions_test.cpp @@ -17,7 +17,7 @@ my_exception: std::exception { char const * - what() const throw() + what() const BOOST_NOEXCEPT_OR_NOTHROW { return "my_exception"; } From f4e1a11e6b90ca49b07ddb1515ccc79418928b0c Mon Sep 17 00:00:00 2001 From: Mike-Devel Date: Sat, 2 Mar 2019 14:20:29 +0100 Subject: [PATCH 07/10] [CMake] Treat Boost.Exception as header only --- CMakeLists.txt | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 29d8424..3db488d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,21 +1,24 @@ # Copyright 2018 Mike Dev # Distributed under the Boost Software License, Version 1.0. -# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt +# See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt # # NOTE: CMake support for Boost.Exception is currently experimental at best # and the interface is likely to change in the future -cmake_minimum_required(VERSION 3.5) -project(BoostException LANGUAGES CXX) +cmake_minimum_required( VERSION 3.5 ) +project( BoostException LANGUAGES CXX ) +# We treat Boost.Exception as header only for now. +# See https://github.com/boostorg/exception/pull/17 +# for more information. -add_library(boost_exception src/clone_current_exception_non_intrusive.cpp) -add_library(Boost::exception ALIAS boost_exception) +add_library( boost_exception INTERFACE ) +add_library( Boost::exception ALIAS boost_exception ) -target_include_directories(boost_exception PUBLIC include) +target_include_directories( boost_exception PUBLIC include ) -target_link_libraries(boost_exception - PUBLIC +target_link_libraries( boost_exception + INTERFACE Boost::assert Boost::config Boost::core From 8d19f99e43903f0476c28b9d85f0cf78debd2060 Mon Sep 17 00:00:00 2001 From: Mike-Devel Date: Sat, 2 Mar 2019 14:24:52 +0100 Subject: [PATCH 08/10] [CMake] Fix copyright date --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3db488d..abde781 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2018 Mike Dev +# Copyright 2019 Mike Dev # Distributed under the Boost Software License, Version 1.0. # See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt # From ef4f541a8a6cc20ba8ef29f48c2aca7de82d7f71 Mon Sep 17 00:00:00 2001 From: Mike-Devel Date: Sun, 3 Mar 2019 07:13:47 +0100 Subject: [PATCH 09/10] [CMake] Fix PUBLIC/INTERFACE left over. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index abde781..db7251b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ project( BoostException LANGUAGES CXX ) add_library( boost_exception INTERFACE ) add_library( Boost::exception ALIAS boost_exception ) -target_include_directories( boost_exception PUBLIC include ) +target_include_directories( boost_exception INTERFACE include ) target_link_libraries( boost_exception INTERFACE From 90694bc3b9d0c1d36e9b1012c68a70276ed27fa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Neum=C3=BCller?= Date: Mon, 11 Mar 2019 17:56:55 +0100 Subject: [PATCH 10/10] Guard diagnostic_information against null what() --- include/boost/exception/diagnostic_information.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/exception/diagnostic_information.hpp b/include/boost/exception/diagnostic_information.hpp index b94ca44..ad22735 100644 --- a/include/boost/exception/diagnostic_information.hpp +++ b/include/boost/exception/diagnostic_information.hpp @@ -161,7 +161,7 @@ boost core::demangle((be?(BOOST_EXCEPTION_DYNAMIC_TYPEID(*be)):(BOOST_EXCEPTION_DYNAMIC_TYPEID(*se))).type_->name()) << '\n'; #endif if( with_what && se && verbose ) - tmp << "std::exception::what: " << wh << '\n'; + tmp << "std::exception::what: " << (wh ? wh : "(null)") << '\n'; if( be ) if( char const * s=exception_detail::get_diagnostic_information(*be,tmp.str().c_str()) ) if( *s )