Compare commits

...

15 Commits

Author SHA1 Message Date
fe23c01a93 Added sudo apt-get update before sudo apt-get install (#54)
* Added sudo apt-get update before sudo apt-get install

* Update gha
2023-08-05 13:19:51 -07:00
ea70868a45 Don't double-rethrow std::exception_ptr (#53)
It's unnecessary to throw and then rethrow std::exception_ptr, just derive clone_base separately.

nb. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110835
2023-08-04 18:28:03 -07:00
03aa58e06e GHA 2023-07-29 19:20:34 -07:00
0d69599d91 GHA update 2023-07-29 18:08:17 -07:00
652e8e01d2 GHA updates 2023-07-29 17:47:11 -07:00
b039b4ea18 Issue #49 2022-12-16 16:14:39 -08:00
89d8033fed Fix two cases of redefinition and hiding of local variables (#46) 2022-11-13 22:04:53 -08:00
bd347f048a refactor use core/enable_if.hpp over utility/enable_if.hpp (#44) 2022-08-31 21:59:50 -07:00
e2faee265d Merge pull request #43 from boostorg/pr/current-exception
Prefer using std::current_exception when available
2022-01-25 19:40:04 -08:00
7df9fc8a85 Merge pull request #41 from boostorg/pr/copy-exception
Use enable_current_exception instead of wrapexcept in copy_exception
2022-01-25 19:39:39 -08:00
9259706f08 Disable exception_ptr_test2 when exceptions aren't enabled 2022-01-26 01:49:45 +02:00
eafe6dbd5c Prefer using std::current_exception when available (refs #42) 2022-01-26 01:12:54 +02:00
941754ed23 Add exception_ptr_test2.cpp 2022-01-26 01:07:46 +02:00
0d205cd71f Use enable_current_exception instead of wrapexcept in copy_exception 2022-01-25 19:54:15 +02:00
b8e9e98b33 Categorized as "Error-handling" in meta/libraries.json 2021-11-06 15:03:14 -07:00
7 changed files with 279 additions and 72 deletions

View File

@ -19,57 +19,80 @@ jobs:
include:
- toolset: gcc-4.8
cxxstd: "03,11"
os: ubuntu-18.04
install: g++-4.8
os: ubuntu-latest
container: ubuntu:18.04
install: g++-4.8-multilib
address-model: 32,64
- toolset: gcc-5
cxxstd: "03,11,14,1z"
os: ubuntu-18.04
install: g++-5
os: ubuntu-latest
container: ubuntu:18.04
install: g++-5-multilib
address-model: 32,64
- toolset: gcc-6
cxxstd: "03,11,14,1z"
os: ubuntu-18.04
install: g++-6
os: ubuntu-latest
container: ubuntu:18.04
install: g++-6-multilib
address-model: 32,64
- toolset: gcc-7
cxxstd: "03,11,14,17"
os: ubuntu-18.04
os: ubuntu-latest
container: ubuntu:18.04
install: g++-7-multilib
address-model: 32,64
- toolset: gcc-8
cxxstd: "03,11,14,17,2a"
os: ubuntu-18.04
install: g++-8
os: ubuntu-20.04
install: g++-8-multilib
address-model: 32,64
- toolset: gcc-9
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
install: g++-9-multilib
address-model: 32,64
- toolset: gcc-10
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
install: g++-10-multilib
address-model: 32,64
- toolset: gcc-11
cxxstd: "03,11,14,17,2a"
cxxstd: "03,11,14,17,20"
os: ubuntu-20.04
install: g++-11
install: g++-11-multilib
address-model: 32,64
- toolset: gcc-12
cxxstd: "03,11,14,17,20,2b"
os: ubuntu-22.04
install: g++-12-multilib
address-model: 32,64
- toolset: clang
compiler: clang++-3.9
cxxstd: "03,11,14"
os: ubuntu-18.04
os: ubuntu-latest
container: ubuntu:18.04
install: clang-3.9
- toolset: clang
compiler: clang++-4.0
cxxstd: "03,11,14"
os: ubuntu-18.04
os: ubuntu-latest
container: ubuntu:18.04
install: clang-4.0
- toolset: clang
compiler: clang++-5.0
cxxstd: "03,11,14,1z"
os: ubuntu-18.04
os: ubuntu-latest
container: ubuntu:18.04
install: clang-5.0
- toolset: clang
compiler: clang++-6.0
cxxstd: "03,11,14,17"
os: ubuntu-18.04
os: ubuntu-20.04
install: clang-6.0
- toolset: clang
compiler: clang++-7
cxxstd: "03,11,14,17"
os: ubuntu-18.04
os: ubuntu-20.04
install: clang-7
- toolset: clang
compiler: clang++-8
@ -85,40 +108,72 @@ jobs:
compiler: clang++-10
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
install: clang-10
- toolset: clang
compiler: clang++-11
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
install: clang-11
- toolset: clang
compiler: clang++-12
cxxstd: "03,11,14,17,2a"
cxxstd: "03,11,14,17,20"
os: ubuntu-20.04
install: clang-12
- toolset: clang
compiler: clang++-13
cxxstd: "03,11,14,17,20,2b"
os: ubuntu-22.04
install: clang-13
- toolset: clang
compiler: clang++-14
cxxstd: "03,11,14,17,20,2b"
os: ubuntu-22.04
install: clang-14
- toolset: clang
cxxstd: "03,11,14,17,2a"
os: macos-10.15
os: macos-11
- toolset: clang
cxxstd: "03,11,14,17,20,2b"
os: macos-12
runs-on: ${{matrix.os}}
container: ${{matrix.container}}
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Setup container environment
if: matrix.container
run: |
apt-get update
apt-get -y install sudo python git g++
- name: Install packages
if: matrix.install
run: sudo apt install ${{matrix.install}}
run: |
sudo apt-get update
sudo apt-get -y install ${{matrix.install}}
- name: Setup Boost
run: |
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
LIBRARY=${GITHUB_REPOSITORY#*/}
echo LIBRARY: $LIBRARY
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
echo GITHUB_REF: $GITHUB_REF
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
REF=${REF#refs/heads/}
echo REF: $REF
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
echo BOOST_BRANCH: $BOOST_BRANCH
cd ..
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
cp -r $GITHUB_WORKSPACE/* libs/exception
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" exception
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
./bootstrap.sh
./b2 -d0 headers
@ -130,21 +185,29 @@ jobs:
- name: Run tests
run: |
cd ../boost-root
./b2 -j3 libs/exception/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} variant=debug,release exception-handling=on,off rtti=on,off link=static,shared visibility=hidden,global
./b2 -j3 libs/$LIBRARY/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} ${ADDRMD:+address-model=$ADDRMD} variant=debug,release exception-handling=on,off rtti=on,off link=static,shared visibility=hidden,global
windows:
strategy:
fail-fast: false
matrix:
include:
- toolset: msvc-14.1
cxxstd: "14,17,latest"
addrmd: 32,64
os: windows-2016
- toolset: msvc-14.2
cxxstd: "14,17,latest"
- toolset: msvc-14.0
cxxstd: 14,latest
addrmd: 32,64
os: windows-2019
- toolset: msvc-14.2
cxxstd: "14,17,20,latest"
addrmd: 32,64
os: windows-2019
- toolset: msvc-14.3
cxxstd: "14,17,20,latest"
addrmd: 32,64
os: windows-2022
- toolset: clang-win
cxxstd: "14,17,latest"
addrmd: 32,64
os: windows-2022
- toolset: gcc
cxxstd: "03,11,14,17,2a"
addrmd: 64
@ -153,20 +216,27 @@ jobs:
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Setup Boost
shell: cmd
run: |
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
echo LIBRARY: %LIBRARY%
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
echo GITHUB_REF: %GITHUB_REF%
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
set BOOST_BRANCH=develop
if "%GITHUB_BASE_REF%" == "master" set BOOST_BRANCH=master
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
echo BOOST_BRANCH: %BOOST_BRANCH%
cd ..
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
xcopy /s /e /q %GITHUB_WORKSPACE% libs\exception\
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" exception
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY%
cmd /c bootstrap
b2 -d0 headers
@ -174,4 +244,5 @@ jobs:
shell: cmd
run: |
cd ../boost-root
b2 -j3 libs/exception/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release exception-handling=on,off rtti=on,off
b2 -j3 libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release exception-handling=on,off rtti=on,off embed-manifest-via=linker

View File

@ -44,28 +44,48 @@ boost
exception_detail
{
#ifndef BOOST_NO_CXX11_HDR_EXCEPTION
struct
std_exception_ptr_wrapper:
std::exception
class
BOOST_SYMBOL_VISIBLE
std_exception_ptr_clone_impl:
public virtual clone_base
{
std::exception_ptr p;
explicit std_exception_ptr_wrapper( std::exception_ptr const & ptr ) BOOST_NOEXCEPT:
p(ptr)
std::exception_ptr p_;
public:
explicit std_exception_ptr_clone_impl( std::exception_ptr const & ptr ) BOOST_NOEXCEPT:
p_(ptr)
{
}
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
explicit std_exception_ptr_wrapper( std::exception_ptr && ptr ) BOOST_NOEXCEPT:
p(static_cast<std::exception_ptr &&>(ptr))
~std_exception_ptr_clone_impl() BOOST_NOEXCEPT_OR_NOTHROW
{
}
#endif
private:
std_exception_ptr_clone_impl( std_exception_ptr_clone_impl const & x ):
p_(x.p_)
{
}
clone_base const*
clone() const
{
return new std_exception_ptr_clone_impl(*this);
}
void
rethrow() const
{
std::rethrow_exception(p_);
}
};
shared_ptr<exception_detail::clone_base const>
inline
wrap_exception_ptr( std::exception_ptr const & e )
{
exception_detail::clone_base const & base =
boost::enable_current_exception(std_exception_ptr_wrapper(std::current_exception()));
exception_detail::clone_base const & base = std_exception_ptr_clone_impl(e);
return shared_ptr<exception_detail::clone_base const>(base.clone());
}
#endif
@ -112,14 +132,24 @@ boost
}
};
namespace
exception_detail
{
template <class E>
inline
exception_ptr
copy_exception_impl( E const & e )
{
return exception_ptr(boost::make_shared<E>(e));
}
}
template <class E>
inline
exception_ptr
copy_exception( E const & e )
{
E cp = e;
exception_detail::copy_boost_exception(&cp, &e);
return exception_ptr(boost::make_shared<wrapexcept<E> >(cp));
return exception_detail::copy_exception_impl(boost::enable_current_exception(e));
}
template <class T>
@ -385,6 +415,9 @@ boost
{
return exception_ptr(shared_ptr<exception_detail::clone_base const>(e.clone()));
}
#ifdef BOOST_NO_CXX11_HDR_EXCEPTION
catch(
std::domain_error & e )
{
@ -457,19 +490,19 @@ 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 )
{
return exception_detail::current_exception_unknown_boost_exception(e);
}
#endif // #ifdef BOOST_NO_CXX11_HDR_EXCEPTION
catch(
... )
{
@ -524,20 +557,7 @@ boost
rethrow_exception_( exception_ptr const & p )
{
BOOST_ASSERT(p);
#if defined( BOOST_NO_CXX11_HDR_EXCEPTION ) || defined( BOOST_NO_EXCEPTIONS )
p.ptr_->rethrow();
#else
try
{
p.ptr_->rethrow();
}
catch(
std_exception_ptr_wrapper const & wrp)
{
// if an std::exception_ptr was wrapped above then rethrow it
std::rethrow_exception(wrp.p);
}
#endif
}
}

View File

@ -9,7 +9,7 @@
#include <boost/config.hpp>
#include <boost/exception/get_error_info.hpp>
#include <boost/exception/info.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/core/enable_if.hpp>
#ifndef BOOST_NO_RTTI
#include <boost/core/demangle.hpp>
#endif
@ -149,11 +149,11 @@ boost
if( f )
{
tmp << *f;
if( int const * l=get_error_info<throw_line>(*be) )
if( l )
tmp << '(' << *l << "): ";
}
tmp << "Throw in function ";
if( char const * const * fn=get_error_info<throw_function>(*be) )
if( fn )
tmp << *fn;
else
tmp << "(unknown)";

View File

@ -6,7 +6,7 @@
#ifndef BOOST_EXCEPTION_7E48761AD92811DC9011477D56D89593
#define BOOST_EXCEPTION_7E48761AD92811DC9011477D56D89593
#include <boost/utility/enable_if.hpp>
#include <boost/core/enable_if.hpp>
#include <boost/exception/detail/is_output_streamable.hpp>
#include <sstream>

View File

@ -7,6 +7,7 @@
"description": "The Boost Exception library supports transporting of arbitrary data in exception objects, and transporting of exceptions between threads.",
"documentation": "doc/boost-exception.html",
"category": [
"Error-handling",
"Emulation"
],
"maintainers": [

View File

@ -41,6 +41,7 @@ run no_exceptions_test.cpp : : : <exception-handling>off ;
run errinfos_test.cpp : : : <exception-handling>on ;
run exception_ptr_test.cpp/<define>BOOST_ENABLE_NON_INTRUSIVE_EXCEPTION_PTR ../../thread/src/tss_null.cpp /boost/exception /boost//thread : : : <threading>multi <exception-handling>on : non_intrusive_exception_ptr_test ;
run exception_ptr_test.cpp ../../thread/src/tss_null.cpp /boost//thread : : : <threading>multi <exception-handling>on ;
run exception_ptr_test2.cpp ;
lib visibility_test_lib : visibility_test_lib.cpp : <visibility>hidden <exception-handling>on ;
run visibility_test.cpp visibility_test_lib/<link>shared : : : <visibility>hidden <exception-handling>on ;

View File

@ -0,0 +1,114 @@
// Copyright 2022 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/config.hpp>
#if defined(BOOST_NO_EXCEPTIONS)
#include <boost/config/pragma_message.hpp>
BOOST_PRAGMA_MESSAGE( "Skipping test because BOOST_NO_EXCEPTIONS is defined" )
int main() {}
#elif defined(BOOST_NO_CXX11_HDR_EXCEPTION)
#include <boost/config/pragma_message.hpp>
BOOST_PRAGMA_MESSAGE( "Skipping test because BOOST_NO_CXX11_HDR_EXCEPTION is defined" )
int main() {}
#else
#include <boost/exception_ptr.hpp>
#include <boost/exception/exception.hpp>
#include <boost/core/lightweight_test.hpp>
#include <exception>
#include <new>
#include <stdexcept>
class my_exception
{
};
class my_exception2: public std::exception
{
};
class my_exception3: public std::bad_alloc
{
};
class my_exception4: public std::exception, public boost::exception
{
};
class my_exception5: public std::logic_error, public virtual boost::exception
{
public:
my_exception5(): std::logic_error( "" ) {}
};
int main()
{
try
{
throw my_exception();
}
catch( ... )
{
boost::exception_ptr p = boost::current_exception();
BOOST_TEST_THROWS( boost::rethrow_exception( p ), my_exception );
}
try
{
throw my_exception2();
}
catch( ... )
{
boost::exception_ptr p = boost::current_exception();
BOOST_TEST_THROWS( boost::rethrow_exception( p ), my_exception2 );
BOOST_TEST_THROWS( boost::rethrow_exception( p ), std::exception );
}
try
{
throw my_exception3();
}
catch( ... )
{
boost::exception_ptr p = boost::current_exception();
BOOST_TEST_THROWS( boost::rethrow_exception( p ), my_exception3 );
BOOST_TEST_THROWS( boost::rethrow_exception( p ), std::bad_alloc );
}
try
{
throw my_exception4();
}
catch( ... )
{
boost::exception_ptr p = boost::current_exception();
BOOST_TEST_THROWS( boost::rethrow_exception( p ), my_exception4 );
BOOST_TEST_THROWS( boost::rethrow_exception( p ), std::exception );
BOOST_TEST_THROWS( boost::rethrow_exception( p ), boost::exception );
}
try
{
throw my_exception5();
}
catch( ... )
{
boost::exception_ptr p = boost::current_exception();
BOOST_TEST_THROWS( boost::rethrow_exception( p ), my_exception5 );
BOOST_TEST_THROWS( boost::rethrow_exception( p ), std::logic_error );
BOOST_TEST_THROWS( boost::rethrow_exception( p ), boost::exception );
}
return boost::report_errors();
}
#endif