From 0036e62dce2412e71cf533f041b6938c9f91aa9d Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Tue, 24 Dec 2019 20:15:08 -0800 Subject: [PATCH 01/10] fixing ABI mismatch error --- .travis.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 507b9eb..7901b99 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,10 +35,6 @@ addons: - clang-3.8 sources: - ubuntu-toolchain-r-test - - llvm-toolchain-precise - - llvm-toolchain-precise-3.6 - - llvm-toolchain-precise-3.7 - - llvm-toolchain-precise-3.8 matrix: From 6bc76ee326e5a435bf4fbdca657516d073ed1bc9 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Sun, 26 Jan 2020 19:33:31 -0800 Subject: [PATCH 02/10] dist: trusty --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 7901b99..9a0f7fd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,8 @@ language: cpp sudo: false +dist: trusty + python: "2.7" os: From 9c8f2b64005389a6993b016e598610fcb346e80d Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Tue, 28 Jan 2020 13:04:55 -0800 Subject: [PATCH 03/10] More travis testing --- .travis.yml | 351 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 317 insertions(+), 34 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7901b99..db5845b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ -# Copyright 2017 Emil Dotchevski -# Copyright 2016 Peter Dimov +# Copyright 2016-2018 Peter Dimov +# Copyright 2018-2019 Emil Dotchevski # Distributed under the Boost Software License, Version 1.0. # (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt) @@ -7,6 +7,8 @@ language: cpp sudo: false +dist: trusty + python: "2.7" os: @@ -17,6 +19,7 @@ branches: only: - master - develop + - /^feature.*/ env: matrix: @@ -25,16 +28,22 @@ env: addons: apt: packages: - - g++-4.7 - - g++-4.8 - g++-4.9 - g++-5 - g++-6 - clang-3.6 - clang-3.7 - clang-3.8 + - ruby-full +# - python-3.6 + - ninja-build + sources: - ubuntu-toolchain-r-test + - llvm-toolchain-precise + - llvm-toolchain-precise-3.6 + - llvm-toolchain-precise-3.7 + - llvm-toolchain-precise-3.8 matrix: @@ -42,53 +51,327 @@ matrix: - env: BOGUS_JOB=true include: - - os: linux - env: TOOLSET=gcc COMPILER=g++ CXXSTD=c++0x - - - os: linux - env: TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=c++0x - - - os: linux - env: TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=c++0x - - - os: linux - env: TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=c++0x - - - os: linux - env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=c++0x - - - os: linux - env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=c++0x - - - os: linux - env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=c++0x - - - os: linux - env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=c++0x - - - os: linux - env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=c++0x - os: osx - env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++0x + osx_image: xcode11.2 + compiler: clang++ + env: TOOLSET=clang COMPILER=clang++ CXXSTD=11,14,1z + + - os: osx + osx_image: xcode11.1 + compiler: clang++ + env: TOOLSET=clang COMPILER=clang++ CXXSTD=11,14,1z + + - os: osx + osx_image: xcode11 + compiler: clang++ + env: TOOLSET=clang COMPILER=clang++ CXXSTD=11,14,1z + + - os: osx + osx_image: xcode10.3 + compiler: clang++ + env: TOOLSET=clang COMPILER=clang++ CXXSTD=11,14,1z + + - os: osx + osx_image: xcode10.2 + compiler: clang++ + env: TOOLSET=clang COMPILER=clang++ CXXSTD=11,14,1z + + - os: osx + osx_image: xcode10.1 + compiler: clang++ + env: TOOLSET=clang COMPILER=clang++ CXXSTD=11,14,1z + + - os: osx + osx_image: xcode10 + compiler: clang++ + env: TOOLSET=clang COMPILER=clang++ CXXSTD=11,14,1z + + - os: osx + osx_image: xcode9.4 + compiler: clang++ + env: TOOLSET=clang COMPILER=clang++ CXXSTD=11,14,1z + + - os: osx + osx_image: xcode9.3 + compiler: clang++ + env: TOOLSET=clang COMPILER=clang++ CXXSTD=11,14,1z + + - os: osx + osx_image: xcode9.2 + compiler: clang++ + env: TOOLSET=clang COMPILER=clang++ CXXSTD=11,14,1z + + - os: osx + osx_image: xcode9.1 + compiler: clang++ + env: TOOLSET=clang COMPILER=clang++ CXXSTD=11,14,1z + + - os: osx + osx_image: xcode9 + compiler: clang++ + env: TOOLSET=clang COMPILER=clang++ CXXSTD=11,14,1z + + - os: osx + osx_image: xcode8.3 + compiler: clang++ + env: TOOLSET=clang COMPILER=clang++ CXXSTD=11,14,1z + + - os: osx + osx_image: xcode8 + compiler: clang++ + env: TOOLSET=clang COMPILER=clang++ CXXSTD=11,14,1z + + - os: osx + compiler: clang++ + env: UBSAN=1 TOOLSET=clang COMPILER=clang++ CXXSTD=11,14,1z UBSAN_OPTIONS=print_stacktrace=1 + + - os: linux + compiler: g++-4.9 + env: TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=11 + addons: + apt: + packages: + - g++-4.9 + sources: + - ubuntu-toolchain-r-test + + - os: linux + compiler: g++-5 + env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=11,14,1z + addons: + apt: + packages: + - g++-5 + sources: + - ubuntu-toolchain-r-test + + - os: linux + compiler: g++-6 + env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=11,14,1z + addons: + apt: + packages: + - g++-6 + sources: + - ubuntu-toolchain-r-test + + - os: linux + compiler: g++-7 + env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=11,14,17 + addons: + apt: + packages: + - g++-7 + sources: + - ubuntu-toolchain-r-test + + - os: linux + compiler: g++-8 + env: TOOLSET=gcc COMPILER=g++-8 CXXSTD=11,14,17 + addons: + apt: + packages: + - g++-8 + sources: + - ubuntu-toolchain-r-test + + - os: linux + compiler: g++-9 + env: TOOLSET=gcc COMPILER=g++-9 CXXSTD=11,14,17,2a + addons: + apt: + packages: + - g++-9 + sources: + - ubuntu-toolchain-r-test + + - os: linux + compiler: g++-9 + env: UBSAN=1 TOOLSET=gcc COMPILER=g++-9 CXXSTD=11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold + addons: + apt: + packages: + - g++-9 + sources: + - ubuntu-toolchain-r-test + + - os: linux + compiler: /usr/bin/clang++ + env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=11 + addons: + apt: + packages: + - clang-3.3 + + - os: linux + compiler: /usr/bin/clang++ + env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=11 + addons: + apt: + packages: + - clang-3.4 + + - os: linux + compiler: clang++ + env: TOOLSET=clang COMPILER=clang++ CXXSTD=11 + + - os: linux + compiler: clang++-3.5 + env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=11,14,1z + addons: + apt: + packages: + - clang-3.5 + - libstdc++-4.9-dev + sources: + - ubuntu-toolchain-r-test + + - os: linux + compiler: clang++-3.6 + env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=11,14,1z + addons: + apt: + packages: + - clang-3.6 + - libstdc++-4.9-dev + sources: + - ubuntu-toolchain-r-test + + - os: linux + compiler: clang++-3.7 + env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=11,14,1z + addons: + apt: + packages: + - clang-3.7 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-precise-3.7 + + - os: linux + compiler: clang++-3.8 + env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=11,14,1z + addons: + apt: + packages: + - clang-3.8 + - libstdc++-4.9-dev + sources: + - ubuntu-toolchain-r-test + + - os: linux + compiler: clang++-3.9 + env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=11,14,1z + addons: + apt: + packages: + - clang-3.9 + - libstdc++-4.9-dev + sources: + - ubuntu-toolchain-r-test + + - os: linux + compiler: clang++-4.0 + env: TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=11,14,1z + addons: + apt: + packages: + - clang-4.0 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-trusty-4.0 + + - os: linux + compiler: clang++-5.0 + env: TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=11,14,1z + addons: + apt: + packages: + - clang-5.0 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-trusty-5.0 + + - os: linux + compiler: clang++-6.0 + env: TOOLSET=clang COMPILER=clang++-6.0 CXXSTD=11,14,17 + addons: + apt: + packages: + - clang-6.0 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-trusty-6.0 + + - os: linux + compiler: clang++-7 + env: TOOLSET=clang COMPILER=clang++-7 CXXSTD=11,14,17,2a + addons: + apt: + packages: + - clang-7 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-trusty-7 + + - os: linux + compiler: clang++-8 + env: TOOLSET=clang COMPILER=clang++-8 CXXSTD=11,14,17,2a + addons: + apt: + packages: + - clang-8 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-trusty-8 + + - os: linux + dist: xenial + compiler: clang++-9 + env: TOOLSET=clang COMPILER=clang++-9 CXXSTD=11,14,17,2a + addons: + apt: + packages: + - clang-9 + sources: + - ubuntu-toolchain-r-test + - sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-9 main' + key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key' + + - os: linux + compiler: clang++-8 + env: UBSAN=1 TOOLSET=clang COMPILER=clang++-8 CXXSTD=11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1 + addons: + apt: + packages: + - clang-8 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-trusty-8 install: + - gem install asciidoctor + - gem install coderay - cd .. - - git clone -b $TRAVIS_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root + - git clone -b master --depth 1 https://github.com/boostorg/boost.git boost-root - cd boost-root - git submodule update --init tools/build - git submodule update --init tools/inspect - git submodule update --init libs/config - git submodule update --init tools/boostdep + - mkdir libs/exception - cp -r $TRAVIS_BUILD_DIR/* libs/exception - python tools/boostdep/depinst/depinst.py exception - ./bootstrap.sh - ./b2 headers + - cd libs/exception script: - |- - echo "using $TOOLSET : : $COMPILER : -std=$CXXSTD ;" > ~/user-config.jam - - ./b2 libs/exception/test toolset=$TOOLSET + echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam + - ../../b2 test toolset=$TOOLSET cxxstd=$CXXSTD variant=debug,release,debug-diagnostics0,release-diagnostics0 ${UBSAN:+cxxflags=-fsanitize=undefined cxxflags=-fno-sanitize-recover=undefined linkflags=-fsanitize=undefined debug-symbols=on} ${LINKFLAGS:+linkflags=$LINKFLAGS} + - ../../b2 exception-handling=off rtti=off test toolset=$TOOLSET cxxstd=$CXXSTD variant=debug,release,debug-diagnostics0,release-diagnostics0 ${UBSAN:+cxxflags=-fsanitize=undefined cxxflags=-fno-sanitize-recover=undefined linkflags=-fsanitize=undefined debug-symbols=on} ${LINKFLAGS:+linkflags=$LINKFLAGS} notifications: email: From 1f90ecc32474b4db62fe38d4f2fe40454c2e41a6 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Tue, 28 Jan 2020 13:18:22 -0800 Subject: [PATCH 04/10] travis --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index db5845b..be43c96 100644 --- a/.travis.yml +++ b/.travis.yml @@ -360,6 +360,7 @@ install: - git submodule update --init tools/inspect - git submodule update --init libs/config - git submodule update --init tools/boostdep + - rm -rf libs/exception - mkdir libs/exception - cp -r $TRAVIS_BUILD_DIR/* libs/exception - python tools/boostdep/depinst/depinst.py exception From c4e5f44e94ff0fde6e5e069ae93194cd89007c13 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Tue, 28 Jan 2020 13:57:53 -0800 Subject: [PATCH 05/10] travis --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index be43c96..cb38f84 100644 --- a/.travis.yml +++ b/.travis.yml @@ -371,8 +371,8 @@ install: script: - |- echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam - - ../../b2 test toolset=$TOOLSET cxxstd=$CXXSTD variant=debug,release,debug-diagnostics0,release-diagnostics0 ${UBSAN:+cxxflags=-fsanitize=undefined cxxflags=-fno-sanitize-recover=undefined linkflags=-fsanitize=undefined debug-symbols=on} ${LINKFLAGS:+linkflags=$LINKFLAGS} - - ../../b2 exception-handling=off rtti=off test toolset=$TOOLSET cxxstd=$CXXSTD variant=debug,release,debug-diagnostics0,release-diagnostics0 ${UBSAN:+cxxflags=-fsanitize=undefined cxxflags=-fno-sanitize-recover=undefined linkflags=-fsanitize=undefined debug-symbols=on} ${LINKFLAGS:+linkflags=$LINKFLAGS} + - ../../b2 test toolset=$TOOLSET cxxstd=$CXXSTD variant=debug,release ${UBSAN:+cxxflags=-fsanitize=undefined cxxflags=-fno-sanitize-recover=undefined linkflags=-fsanitize=undefined debug-symbols=on} ${LINKFLAGS:+linkflags=$LINKFLAGS} + - ../../b2 exception-handling=off rtti=off test toolset=$TOOLSET cxxstd=$CXXSTD variant=debug,release ${UBSAN:+cxxflags=-fsanitize=undefined cxxflags=-fno-sanitize-recover=undefined linkflags=-fsanitize=undefined debug-symbols=on} ${LINKFLAGS:+linkflags=$LINKFLAGS} notifications: email: From e8c57591a3f5617726b1358eb4e6b26b44036937 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Tue, 28 Jan 2020 16:39:28 -0800 Subject: [PATCH 06/10] Missing #include in tests --- test/2-throw_exception_no_exceptions_test.cpp | 1 + test/4-throw_exception_no_both_test.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/test/2-throw_exception_no_exceptions_test.cpp b/test/2-throw_exception_no_exceptions_test.cpp index 02f0e96..5d70ca1 100644 --- a/test/2-throw_exception_no_exceptions_test.cpp +++ b/test/2-throw_exception_no_exceptions_test.cpp @@ -5,6 +5,7 @@ #define BOOST_NO_EXCEPTIONS #include +#include class my_exception: public std::exception { }; diff --git a/test/4-throw_exception_no_both_test.cpp b/test/4-throw_exception_no_both_test.cpp index 421ad45..93708e8 100644 --- a/test/4-throw_exception_no_both_test.cpp +++ b/test/4-throw_exception_no_both_test.cpp @@ -6,6 +6,7 @@ #define BOOST_NO_EXCEPTIONS #define BOOST_EXCEPTION_DISABLE #include +#include class my_exception: public std::exception { }; From f68cd7b2d4eb489529970f74fc0004b41f879f60 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Tue, 28 Jan 2020 20:11:17 -0800 Subject: [PATCH 07/10] More g++ testing on travis --- .travis.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/.travis.yml b/.travis.yml index cb38f84..db3249a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -126,6 +126,26 @@ matrix: compiler: clang++ env: UBSAN=1 TOOLSET=clang COMPILER=clang++ CXXSTD=11,14,1z UBSAN_OPTIONS=print_stacktrace=1 + - os: linux + compiler: g++-4.7 + env: TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=11 + addons: + apt: + packages: + - g++-4.7 + sources: + - ubuntu-toolchain-r-test + + - os: linux + compiler: g++-4.8 + env: TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=11 + addons: + apt: + packages: + - g++-4.8 + sources: + - ubuntu-toolchain-r-test + - os: linux compiler: g++-4.9 env: TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=11 From af98afb3d140c076e27fb8b1adaa1d25624982fd Mon Sep 17 00:00:00 2001 From: dmenendez-gruposantander <50944968+dmenendez-gruposantander@users.noreply.github.com> Date: Wed, 29 Jan 2020 22:41:48 +0100 Subject: [PATCH 08/10] Attempt to solve issue #10 (#24) * Attempt to solve issue #10 In boost::current_exception(), after all supported types of exception have been checked for, a boost::unknown_exception is stored in the boost::exception_ptr as a last resort to signal that an exception was indeed stored, but that the actual type and value of the exception was lost. Now, in case C++11 std::current_exception() is supported, the std::exception_ptr result of calling std::current_exception() is what gets stored inside the boost::exception_ptr. Later, inside boost::rethrow_exception, the std::exception_ptr is retrieved from the boost::exception_ptr and whatever exception it stores is thrown via std::rethrow_exception(). The main benefit is than now any exception thrown via plain 'throw' can be trasnported via boost::exception_ptr. Before this change it was required that the throw site either used boost::enable_current_exception() or boost::throw_exception() or threw an exception type inheriting from boost::exception, which was impossible for third party software that does not use Boost.Exception. The detection of std::current_exception() is currently done via config macro BOOST_NO_CXX11_NOEXCEPT, assuming that if 'noexcept' is supported then std::exception_ptr is also supported. A better solution would require a new dedicated macro in Boost.Config. * Detect support for std::current_exception() via config macro BOOST_NO_CXX11_HDR_EXCEPTION The temporary solution via BOOST_NO_CXX11_NOEXCEPT was an ugly hack that is no longer necessary now that Boost.Config has BOOST_NO_CXX11_HDR_EXCEPTION (pending merge to develop). * Attempt to solve issue #10 In boost::current_exception(), after all supported types of exception have been checked for, a boost::unknown_exception is stored in the boost::exception_ptr as a last resort to signal that an exception was indeed stored, but that the actual type and value of the exception was lost. Now, in case C++11 std::current_exception() is supported, the std::exception_ptr result of calling std::current_exception() is what gets stored inside the boost::exception_ptr. Later, inside boost::rethrow_exception, the std::exception_ptr is retrieved from the boost::exception_ptr and whatever exception it stores is thrown via std::rethrow_exception(). The main benefit is than now any exception thrown via plain 'throw' can be trasnported via boost::exception_ptr. Before this change it was required that the throw site either used boost::enable_current_exception() or boost::throw_exception() or threw an exception type inheriting from boost::exception, which was impossible for third party software that does not use Boost.Exception. The detection of std::current_exception() is currently done via config macro BOOST_NO_CXX11_NOEXCEPT, assuming that if 'noexcept' is supported then std::exception_ptr is also supported. A better solution would require a new dedicated macro in Boost.Config. * Detect support for std::current_exception() via config macro BOOST_NO_CXX11_HDR_EXCEPTION The temporary solution via BOOST_NO_CXX11_NOEXCEPT was an ugly hack that is no longer necessary now that Boost.Config has BOOST_NO_CXX11_HDR_EXCEPTION (pending merge to develop). * Document detection of C++11 std::current_exception through BOOST_NO_CXX11_HDR_EXCEPTION * Added dist: trusty for Travis config, as recommended by pdimov in issue #10 * Stupid gcc 4.7 and 4.8 are confused initializing a reference with braces, using equal sign hoping it works (tested similar code on godbolt). --- doc/current_exception.html | 2 +- .../boost/exception/detail/exception_ptr.hpp | 31 +++++ test/unknown_exception_test.cpp | 129 ++++++++++++++++++ 3 files changed, 161 insertions(+), 1 deletion(-) diff --git a/doc/current_exception.html b/doc/current_exception.html index d8b369b..b213da9 100644 --- a/doc/current_exception.html +++ b/doc/current_exception.html @@ -38,7 +38,7 @@ boost

Nothing.

Notes:

  • It is unspecified whether the return values of two successive calls to current_exception refer to the same exception object.
  • -
  • Correct implementation of current_exception may require compiler support, unless enable_current_exception was used at the time the currently handled exception object was passed to throw. Whenever current_exception fails to properly copy the current exception object, it returns an exception_ptr to an object of type that is as close as possible to the original exception type, using unknown_exception as a final fallback. All such types derive from boost::exception, and:
    • if the original exception object derives from boost::exception, then the boost::exception sub-object of the object referred to by the returned exception_ptr is initialized by the boost::exception copy constructor;
    • +
    • Correct implementation of current_exception may require compiler support (e.g. C++11 std::current_exception() is used when available, as specified by Boost.Config BOOST_NO_CXX11_HDR_EXCEPTION), unless enable_current_exception was used at the time the currently handled exception object was passed to throw. Whenever current_exception fails to properly copy the current exception object, it returns an exception_ptr to an object of type that is as close as possible to the original exception type, using unknown_exception as a final fallback. All such types derive from boost::exception, and:
    • diff --git a/include/boost/exception/detail/exception_ptr.hpp b/include/boost/exception/detail/exception_ptr.hpp index d4eba62..c106ce2 100644 --- a/include/boost/exception/detail/exception_ptr.hpp +++ b/include/boost/exception/detail/exception_ptr.hpp @@ -412,11 +412,14 @@ boost { return exception_detail::current_exception_std_exception(e); } +#ifdef BOOST_NO_CXX11_HDR_EXCEPTION + // this case can be handled losslesly with std::current_exception() (see below) catch( std::exception & e ) { return exception_detail::current_exception_unknown_std_exception(e); } +#endif catch( boost::exception & e ) { @@ -425,7 +428,22 @@ boost catch( ... ) { +#ifndef BOOST_NO_CXX11_HDR_EXCEPTION + try + { + // wrap the std::exception_ptr in a clone-enabled Boost.Exception object + exception_detail::clone_base const& base = + boost::enable_current_exception(std::current_exception()); + return exception_ptr(shared_ptr(base.clone())); + } + catch( + ...) + { + return exception_detail::current_exception_unknown_exception(); + } +#else return exception_detail::current_exception_unknown_exception(); +#endif } } } @@ -461,7 +479,20 @@ boost rethrow_exception( exception_ptr const & p ) { BOOST_ASSERT(p); +#ifndef BOOST_NO_CXX11_HDR_EXCEPTION + try + { + p.ptr_->rethrow(); + } + catch( + const std::exception_ptr& std_ep) + { + // if an std::exception_ptr was wrapped above then rethrow it + std::rethrow_exception(std_ep); + } +#else p.ptr_->rethrow(); +#endif BOOST_ASSERT(0); #if defined(UNDER_CE) // some CE platforms don't define ::abort() diff --git a/test/unknown_exception_test.cpp b/test/unknown_exception_test.cpp index bf474ba..8bed4c6 100644 --- a/test/unknown_exception_test.cpp +++ b/test/unknown_exception_test.cpp @@ -38,6 +38,25 @@ throw_unknown_exception() throw test_exception(); } +struct +user_defined_exception + { + user_defined_exception(int d):data(d){} + int data; + }; + +void +throw_user_defined_exception() + { + throw user_defined_exception(42); + } + +void +throw_builtin_exception() + { + throw 42; + } + int main() { @@ -138,5 +157,115 @@ main() BOOST_TEST(false); } } + try + { + throw_user_defined_exception(); + } + catch( + ... ) + { + boost::exception_ptr ep=boost::current_exception(); + try + { + rethrow_exception(ep); + } +#ifndef BOOST_NO_CXX11_HDR_EXCEPTION + catch( + user_defined_exception & x) + { + //Yay! std::current_exception to the rescue! + BOOST_TEST( 42==x.data ); + } +#else + catch( + boost::unknown_exception & ) + { + //Boo! user defined exception was transported as a boost::unknown_exception + } +#endif + catch( + ... ) + { + BOOST_TEST(false); + } + try + { + rethrow_exception(ep); + } +#ifndef BOOST_NO_CXX11_HDR_EXCEPTION + catch( + user_defined_exception & x) + { + //Yay! std::current_exception to the rescue! + BOOST_TEST( 42==x.data ); + } +#else + catch( + boost::unknown_exception & ) + { + //Boo! user defined exception was transported as a boost::unknown_exception + } +#endif + catch( + ... ) + { + BOOST_TEST(false); + } + } + try + { + throw_builtin_exception(); + } + catch( + ... ) + { + boost::exception_ptr ep=boost::current_exception(); + try + { + rethrow_exception(ep); + } +#ifndef BOOST_NO_CXX11_HDR_EXCEPTION + catch( + int & x) + { + //Yay! std::current_exception to the rescue! + BOOST_TEST( 42==x ); + } +#else + catch( + boost::unknown_exception & ) + { + //Boo! builtin exception was transported as a boost::unknown_exception + } +#endif + catch( + ... ) + { + BOOST_TEST(false); + } + try + { + rethrow_exception(ep); + } +#ifndef BOOST_NO_CXX11_HDR_EXCEPTION + catch( + int & x) + { + //Yay! std::current_exception to the rescue! + BOOST_TEST( 42==x ); + } +#else + catch( + boost::unknown_exception & ) + { + //Boo! builtin exception was transported as a boost::unknown_exception + } +#endif + catch( + ... ) + { + BOOST_TEST(false); + } + } return boost::report_errors(); } From 3f6ff1a8bf9fdbfc8dd97c7bdfdc528cb0ff2382 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Wed, 29 Jan 2020 14:02:40 -0800 Subject: [PATCH 09/10] std_exception_ptr_wrapper --- include/boost/exception/detail/exception_ptr.hpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/include/boost/exception/detail/exception_ptr.hpp b/include/boost/exception/detail/exception_ptr.hpp index c106ce2..fe8a06c 100644 --- a/include/boost/exception/detail/exception_ptr.hpp +++ b/include/boost/exception/detail/exception_ptr.hpp @@ -299,6 +299,14 @@ boost return boost::copy_exception(unknown_exception(e)); } +#ifndef BOOST_NO_CXX11_HDR_EXCEPTION + struct + std_exception_ptr_wrapper + { + std::exception_ptr p; + }; +#endif + inline exception_ptr current_exception_impl() @@ -432,8 +440,8 @@ boost try { // wrap the std::exception_ptr in a clone-enabled Boost.Exception object - exception_detail::clone_base const& base = - boost::enable_current_exception(std::current_exception()); + exception_detail::clone_base const & base = + boost::enable_current_exception(std_exception_ptr_wrapper{std::current_exception()}); return exception_ptr(shared_ptr(base.clone())); } catch( @@ -485,10 +493,10 @@ boost p.ptr_->rethrow(); } catch( - const std::exception_ptr& std_ep) + exception_detail::std_exception_ptr_wrapper const & wrp) { // if an std::exception_ptr was wrapped above then rethrow it - std::rethrow_exception(std_ep); + std::rethrow_exception(wrp.p); } #else p.ptr_->rethrow(); From 81e9a137eb4a522a0a9753eaa5d6a8a9b5d5c919 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Wed, 29 Jan 2020 14:05:11 -0800 Subject: [PATCH 10/10] Added testing for CXXSTD 98, 03 --- .travis.yml | 78 ++++++++++++++++++++++++++--------------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/.travis.yml b/.travis.yml index db3249a..70102e2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -55,80 +55,80 @@ matrix: - os: osx osx_image: xcode11.2 compiler: clang++ - env: TOOLSET=clang COMPILER=clang++ CXXSTD=11,14,1z + env: TOOLSET=clang COMPILER=clang++ CXXSTD=98,03,11,14,1z - os: osx osx_image: xcode11.1 compiler: clang++ - env: TOOLSET=clang COMPILER=clang++ CXXSTD=11,14,1z + env: TOOLSET=clang COMPILER=clang++ CXXSTD=98,03,11,14,1z - os: osx osx_image: xcode11 compiler: clang++ - env: TOOLSET=clang COMPILER=clang++ CXXSTD=11,14,1z + env: TOOLSET=clang COMPILER=clang++ CXXSTD=98,03,11,14,1z - os: osx osx_image: xcode10.3 compiler: clang++ - env: TOOLSET=clang COMPILER=clang++ CXXSTD=11,14,1z + env: TOOLSET=clang COMPILER=clang++ CXXSTD=98,03,11,14,1z - os: osx osx_image: xcode10.2 compiler: clang++ - env: TOOLSET=clang COMPILER=clang++ CXXSTD=11,14,1z + env: TOOLSET=clang COMPILER=clang++ CXXSTD=98,03,11,14,1z - os: osx osx_image: xcode10.1 compiler: clang++ - env: TOOLSET=clang COMPILER=clang++ CXXSTD=11,14,1z + env: TOOLSET=clang COMPILER=clang++ CXXSTD=98,03,11,14,1z - os: osx osx_image: xcode10 compiler: clang++ - env: TOOLSET=clang COMPILER=clang++ CXXSTD=11,14,1z + env: TOOLSET=clang COMPILER=clang++ CXXSTD=98,03,11,14,1z - os: osx osx_image: xcode9.4 compiler: clang++ - env: TOOLSET=clang COMPILER=clang++ CXXSTD=11,14,1z + env: TOOLSET=clang COMPILER=clang++ CXXSTD=98,03,11,14,1z - os: osx osx_image: xcode9.3 compiler: clang++ - env: TOOLSET=clang COMPILER=clang++ CXXSTD=11,14,1z + env: TOOLSET=clang COMPILER=clang++ CXXSTD=98,03,11,14,1z - os: osx osx_image: xcode9.2 compiler: clang++ - env: TOOLSET=clang COMPILER=clang++ CXXSTD=11,14,1z + env: TOOLSET=clang COMPILER=clang++ CXXSTD=98,03,11,14,1z - os: osx osx_image: xcode9.1 compiler: clang++ - env: TOOLSET=clang COMPILER=clang++ CXXSTD=11,14,1z + env: TOOLSET=clang COMPILER=clang++ CXXSTD=98,03,11,14,1z - os: osx osx_image: xcode9 compiler: clang++ - env: TOOLSET=clang COMPILER=clang++ CXXSTD=11,14,1z + env: TOOLSET=clang COMPILER=clang++ CXXSTD=98,03,11,14,1z - os: osx osx_image: xcode8.3 compiler: clang++ - env: TOOLSET=clang COMPILER=clang++ CXXSTD=11,14,1z + env: TOOLSET=clang COMPILER=clang++ CXXSTD=98,03,11,14,1z - os: osx osx_image: xcode8 compiler: clang++ - env: TOOLSET=clang COMPILER=clang++ CXXSTD=11,14,1z + env: TOOLSET=clang COMPILER=clang++ CXXSTD=98,03,11,14,1z - os: osx compiler: clang++ - env: UBSAN=1 TOOLSET=clang COMPILER=clang++ CXXSTD=11,14,1z UBSAN_OPTIONS=print_stacktrace=1 + env: UBSAN=1 TOOLSET=clang COMPILER=clang++ CXXSTD=98,03,11,14,1z UBSAN_OPTIONS=print_stacktrace=1 - os: linux compiler: g++-4.7 - env: TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=11 + env: TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=98,03,11 addons: apt: packages: @@ -138,7 +138,7 @@ matrix: - os: linux compiler: g++-4.8 - env: TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=11 + env: TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=98,03,11 addons: apt: packages: @@ -148,7 +148,7 @@ matrix: - os: linux compiler: g++-4.9 - env: TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=11 + env: TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=98,03,11 addons: apt: packages: @@ -158,7 +158,7 @@ matrix: - os: linux compiler: g++-5 - env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=11,14,1z + env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=98,03,11,14,1z addons: apt: packages: @@ -168,7 +168,7 @@ matrix: - os: linux compiler: g++-6 - env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=11,14,1z + env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=98,03,11,14,1z addons: apt: packages: @@ -178,7 +178,7 @@ matrix: - os: linux compiler: g++-7 - env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=11,14,17 + env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=98,03,11,14,17 addons: apt: packages: @@ -188,7 +188,7 @@ matrix: - os: linux compiler: g++-8 - env: TOOLSET=gcc COMPILER=g++-8 CXXSTD=11,14,17 + env: TOOLSET=gcc COMPILER=g++-8 CXXSTD=98,03,11,14,17 addons: apt: packages: @@ -198,7 +198,7 @@ matrix: - os: linux compiler: g++-9 - env: TOOLSET=gcc COMPILER=g++-9 CXXSTD=11,14,17,2a + env: TOOLSET=gcc COMPILER=g++-9 CXXSTD=98,03,11,14,17,2a addons: apt: packages: @@ -208,7 +208,7 @@ matrix: - os: linux compiler: g++-9 - env: UBSAN=1 TOOLSET=gcc COMPILER=g++-9 CXXSTD=11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold + env: UBSAN=1 TOOLSET=gcc COMPILER=g++-9 CXXSTD=98,03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold addons: apt: packages: @@ -218,7 +218,7 @@ matrix: - os: linux compiler: /usr/bin/clang++ - env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=11 + env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=98,03,11 addons: apt: packages: @@ -226,7 +226,7 @@ matrix: - os: linux compiler: /usr/bin/clang++ - env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=11 + env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=98,03,11 addons: apt: packages: @@ -234,11 +234,11 @@ matrix: - os: linux compiler: clang++ - env: TOOLSET=clang COMPILER=clang++ CXXSTD=11 + env: TOOLSET=clang COMPILER=clang++ CXXSTD=98,03,11 - os: linux compiler: clang++-3.5 - env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=11,14,1z + env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=98,03,11,14,1z addons: apt: packages: @@ -249,7 +249,7 @@ matrix: - os: linux compiler: clang++-3.6 - env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=11,14,1z + env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=98,03,11,14,1z addons: apt: packages: @@ -260,7 +260,7 @@ matrix: - os: linux compiler: clang++-3.7 - env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=11,14,1z + env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=98,03,11,14,1z addons: apt: packages: @@ -271,7 +271,7 @@ matrix: - os: linux compiler: clang++-3.8 - env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=11,14,1z + env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=98,03,11,14,1z addons: apt: packages: @@ -282,7 +282,7 @@ matrix: - os: linux compiler: clang++-3.9 - env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=11,14,1z + env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=98,03,11,14,1z addons: apt: packages: @@ -293,7 +293,7 @@ matrix: - os: linux compiler: clang++-4.0 - env: TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=11,14,1z + env: TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=98,03,11,14,1z addons: apt: packages: @@ -304,7 +304,7 @@ matrix: - os: linux compiler: clang++-5.0 - env: TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=11,14,1z + env: TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=98,03,11,14,1z addons: apt: packages: @@ -315,7 +315,7 @@ matrix: - os: linux compiler: clang++-6.0 - env: TOOLSET=clang COMPILER=clang++-6.0 CXXSTD=11,14,17 + env: TOOLSET=clang COMPILER=clang++-6.0 CXXSTD=98,03,11,14,17 addons: apt: packages: @@ -326,7 +326,7 @@ matrix: - os: linux compiler: clang++-7 - env: TOOLSET=clang COMPILER=clang++-7 CXXSTD=11,14,17,2a + env: TOOLSET=clang COMPILER=clang++-7 CXXSTD=98,03,11,14,17,2a addons: apt: packages: @@ -337,7 +337,7 @@ matrix: - os: linux compiler: clang++-8 - env: TOOLSET=clang COMPILER=clang++-8 CXXSTD=11,14,17,2a + env: TOOLSET=clang COMPILER=clang++-8 CXXSTD=98,03,11,14,17,2a addons: apt: packages: @@ -349,7 +349,7 @@ matrix: - os: linux dist: xenial compiler: clang++-9 - env: TOOLSET=clang COMPILER=clang++-9 CXXSTD=11,14,17,2a + env: TOOLSET=clang COMPILER=clang++-9 CXXSTD=98,03,11,14,17,2a addons: apt: packages: @@ -361,7 +361,7 @@ matrix: - os: linux compiler: clang++-8 - env: UBSAN=1 TOOLSET=clang COMPILER=clang++-8 CXXSTD=11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1 + env: UBSAN=1 TOOLSET=clang COMPILER=clang++-8 CXXSTD=98,03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1 addons: apt: packages: