Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set BOOST_NO_EXCEPTIONS and BOOST_NO_RTTI for GCC and math in standal… #786

Merged
merged 19 commits into from
May 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
926e34c
Set BOOST_NO_EXCEPTIONS and BOOST_NO_RTTI for GCC and math in standal…
jzmaddock May 12, 2022
a6db2d1
Change bernoulli error handling to always go through the policies.
jzmaddock May 13, 2022
bf3b025
Correct error handling in owens_t.
jzmaddock May 13, 2022
6240f57
Enclose a try/catch block within (no)-exceptions
ckormanyos May 14, 2022
7c5228a
Add no-exception handling tests.
jzmaddock May 15, 2022
c2ce062
Merge branch 'no_exceptions_or_rtti_error_handling' of https://github…
jzmaddock May 15, 2022
6869066
Disable chebeshev_transform testing in no-eh mode.
jzmaddock May 16, 2022
0edd1a2
Try building with -j2 in ubuntu-22 CI.
jzmaddock May 16, 2022
990704e
Correct #include logic in test_hyperexponential_dist.cpp.
jzmaddock May 23, 2022
8126947
Split up 1F0 and 2F0 tests.
jzmaddock May 24, 2022
536851a
Change naked throws to BOOST_MATH_THROW_EXCEPTION.
jzmaddock May 24, 2022
3fa245d
Strip CI back to minimal failing test cases.
jzmaddock May 26, 2022
355237e
Add missing #include to chebeshev.hpp.
jzmaddock May 26, 2022
378b6a2
Disable gcc-12 C++20 testing as it runs the machine out of memory com…
jzmaddock May 26, 2022
1781333
Revert "Strip CI back to minimal failing test cases."
jzmaddock May 26, 2022
8f808da
Disable test_2F0 MP tests for all gcc-12.
jzmaddock May 27, 2022
25e51f7
Fix condition_numbers.hpp for no-eh usage.
jzmaddock May 27, 2022
b50452b
Merge branch 'develop' into no_exceptions_or_rtti_error_handling
jzmaddock May 30, 2022
14d6cfd
Tweak CI runs:
jzmaddock May 30, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ windowsglobalimage="cppalliance/dronevs2019"
def main(ctx):

things_to_test = [ "special_fun", "distribution_tests", "mp", "misc", "interpolators", "quadrature", "autodiff", "long-running-tests", "float128_tests" ]
sanitizer_test = [ "special_fun", "distribution_tests", "misc", "interpolators", "quadrature", "autodiff", "float128_tests" ]
sanitizer_test = [ "special_fun", "distribution_tests", "misc", "interpolators", "quadrature", "float128_tests" ]
gnu_5_stds = [ "gnu++11" ]
gnu_6_stds = [ "gnu++11", "gnu++14" ]
gnu_8_stds = [ "gnu++11", "gnu++14", "gnu++17" ]
Expand Down
131 changes: 129 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,77 @@ on:
release:
types: [published, created, edited]
jobs:
ubuntu-jammy:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
compiler: [ g++-12, clang++-14 ]
standard: [ c++14, c++17, c++20 ]
suite: [ float128_tests, special_fun, distribution_tests, misc, quadrature, mp, interpolators, autodiff, ../example//examples, ../tools ]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: '0'
- uses: mstachniuk/ci-skip@v1
with:
commit-filter: '[skip ci];[ci skip];[CI SKIP];[SKIP CI];***CI SKIP***;***SKIP CI***;[windows];[Windows];[WINDOWS];[apple];[Apple];[APPLE];[standalone];[STANDALONE];[cygwin];[CYGWIN]'
commit-filter-separator: ';'
fail-fast: true
- name: Set TOOLSET
run: echo ${{ matrix.compiler }} | awk '/^g/ { print "TOOLSET=gcc" } /^clang/ { print "TOOLSET=clang" }' >> $GITHUB_ENV
- name: Add repository
continue-on-error: true
id: addrepo
run: sudo apt-add-repository -y "ppa:ubuntu-toolchain-r/test"
- name: Retry Add Repo
continue-on-error: true
id: retry1
if: steps.addrepo.outcome=='failure'
run: sudo apt-add-repository -y "ppa:ubuntu-toolchain-r/test"
- name: Retry Add Repo 2
continue-on-error: true
id: retry2
if: steps.retry1.outcome=='failure'
run: sudo apt-add-repository -y "ppa:ubuntu-toolchain-r/test"
- name: Install packages
run: sudo apt install g++-12 clang-14 libgmp-dev libmpfr-dev libfftw3-dev
- name: Checkout main boost
run: git clone -b develop --depth 1 https://github.com/boostorg/boost.git ../boost-root
- name: Update tools/boostdep
run: git submodule update --init tools/boostdep
working-directory: ../boost-root
- name: Copy files
run: cp -r $GITHUB_WORKSPACE/* libs/math
working-directory: ../boost-root
- name: Install deps
run: python tools/boostdep/depinst/depinst.py math
working-directory: ../boost-root
- name: Bootstrap
run: ./bootstrap.sh
working-directory: ../boost-root
- name: Generate headers
run: ./b2 headers
working-directory: ../boost-root
- name: Generate user config
run: 'echo "using $TOOLSET : : ${{ matrix.compiler }} : <cxxflags>-std=${{ matrix.standard }} ;" > ~/user-config.jam'
working-directory: ../boost-root
- name: Config info install
run: ../../../b2 config_info_travis_install toolset=$TOOLSET
working-directory: ../boost-root/libs/config/test
- name: Config info
run: ./config_info_travis
working-directory: ../boost-root/libs/config/test
- name: Test
run: ../../../b2 -j2 toolset=$TOOLSET ${{ matrix.suite }} define=CI_SUPPRESS_KNOWN_ISSUES define=SLOW_COMPILER
working-directory: ../boost-root/libs/math/test
ubuntu-focal:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
compiler: [ g++-9, g++-11, clang++-10 ]
standard: [ c++11, c++14, c++17, c++2a ]
standard: [ c++14, c++17, c++2a ]
suite: [ float128_tests, special_fun, distribution_tests, misc, quadrature, mp, interpolators, autodiff, ../example//examples, ../tools ]
steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -77,6 +141,69 @@ jobs:
- name: Test
run: ../../../b2 toolset=$TOOLSET ${{ matrix.suite }} define=CI_SUPPRESS_KNOWN_ISSUES define=SLOW_COMPILER
working-directory: ../boost-root/libs/math/test
ubuntu-focal-no-eh:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
compiler: [ g++-9, g++-11, clang++-10 ]
standard: [ c++11, c++14, c++17, c++2a ]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: '0'
- uses: mstachniuk/ci-skip@v1
with:
commit-filter: '[skip ci];[ci skip];[CI SKIP];[SKIP CI];***CI SKIP***;***SKIP CI***;[windows];[Windows];[WINDOWS];[apple];[Apple];[APPLE];[standalone];[STANDALONE];[cygwin];[CYGWIN]'
commit-filter-separator: ';'
fail-fast: true
- name: Set TOOLSET
run: echo ${{ matrix.compiler }} | awk '/^g/ { print "TOOLSET=gcc" } /^clang/ { print "TOOLSET=clang" }' >> $GITHUB_ENV
- name: Add repository
continue-on-error: true
id: addrepo
run: sudo apt-add-repository -y "ppa:ubuntu-toolchain-r/test"
- name: Retry Add Repo
continue-on-error: true
id: retry1
if: steps.addrepo.outcome=='failure'
run: sudo apt-add-repository -y "ppa:ubuntu-toolchain-r/test"
- name: Retry Add Repo 2
continue-on-error: true
id: retry2
if: steps.retry1.outcome=='failure'
run: sudo apt-add-repository -y "ppa:ubuntu-toolchain-r/test"
- name: Install packages
run: sudo apt install g++-9 g++-11 clang-9 clang-10 libgmp-dev libmpfr-dev libfftw3-dev
- name: Checkout main boost
run: git clone -b develop --depth 1 https://github.com/boostorg/boost.git ../boost-root
- name: Update tools/boostdep
run: git submodule update --init tools/boostdep
working-directory: ../boost-root
- name: Copy files
run: cp -r $GITHUB_WORKSPACE/* libs/math
working-directory: ../boost-root
- name: Install deps
run: python tools/boostdep/depinst/depinst.py math
working-directory: ../boost-root
- name: Bootstrap
run: ./bootstrap.sh
working-directory: ../boost-root
- name: Generate headers
run: ./b2 headers
working-directory: ../boost-root
- name: Generate user config
run: 'echo "using $TOOLSET : : ${{ matrix.compiler }} : <cxxflags>-std=${{ matrix.standard }} ;" > ~/user-config.jam'
working-directory: ../boost-root
- name: Config info install
run: ../../../b2 config_info_travis_install toolset=$TOOLSET
working-directory: ../boost-root/libs/config/test
- name: Config info
run: ./config_info_travis
working-directory: ../boost-root/libs/config/test
- name: Test
run: ../../../b2 toolset=$TOOLSET no_eh_tests exception-handling=off rtti=off define=CI_SUPPRESS_KNOWN_ISSUES define=SLOW_COMPILER
working-directory: ../boost-root/libs/math/test
ubuntu-bionic:
runs-on: ubuntu-18.04
strategy:
Expand Down Expand Up @@ -147,7 +274,7 @@ jobs:
fail-fast: false
matrix:
toolset: [ clang ]
standard: [ 11, 14, 17, 2a ]
standard: [ 11, 14, 17, 20 ]
suite: [ float128_tests, special_fun, distribution_tests, misc, quadrature, mp, interpolators, autodiff, ../example//examples, ../tools ]
steps:
- uses: actions/checkout@v2
Expand Down
51 changes: 48 additions & 3 deletions include/boost/math/policies/error_handling.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,23 @@
#ifndef BOOST_MATH_POLICY_ERROR_HANDLING_HPP
#define BOOST_MATH_POLICY_ERROR_HANDLING_HPP

#include <boost/math/tools/config.hpp>
#include <iomanip>
#include <string>
#include <cstring>
#ifndef BOOST_NO_RTTI
#include <typeinfo>
#endif
#include <cerrno>
#include <complex>
#include <cmath>
#include <cstdint>
#include <stdexcept>
#include <boost/math/tools/config.hpp>
#include <boost/math/policies/policy.hpp>
#include <boost/math/tools/precision.hpp>
#ifndef BOOST_NO_EXCEPTIONS
#include <stdexcept>
#include <boost/math/tools/throw_exception.hpp>
#endif

#ifdef _MSC_VER
# pragma warning(push) // Quiet warnings in boost/format.hpp
Expand All @@ -36,6 +40,8 @@

namespace boost{ namespace math{

#ifndef BOOST_NO_EXCEPTIONS

class evaluation_error : public std::runtime_error
{
public:
Expand All @@ -48,6 +54,8 @@ class rounding_error : public std::runtime_error
rounding_error(const std::string& s) : std::runtime_error(s){}
};

#endif

namespace policies{
//
// Forward declarations of user error handlers,
Expand Down Expand Up @@ -120,6 +128,7 @@ inline const char* name_of<BOOST_MATH_FLOAT128_TYPE>()
}
#endif

#ifndef BOOST_NO_EXCEPTIONS
template <class E, class T>
void raise_error(const char* pfunction, const char* message)
{
Expand Down Expand Up @@ -169,6 +178,7 @@ void raise_error(const char* pfunction, const char* pmessage, const T& val)
E e(msg);
BOOST_MATH_THROW_EXCEPTION(e)
}
#endif

template <class T>
inline T raise_domain_error(
Expand All @@ -177,9 +187,13 @@ inline T raise_domain_error(
const T& val,
const ::boost::math::policies::domain_error< ::boost::math::policies::throw_on_error>&)
{
#ifdef BOOST_NO_EXCEPTIONS
static_assert(sizeof(T) == 0, "Error handler called with throw_on_error and BOOST_NO_EXCEPTIONS set.");
#else
raise_error<std::domain_error, T>(function, message, val);
// we never get here:
return std::numeric_limits<T>::quiet_NaN();
#endif
}

template <class T>
Expand Down Expand Up @@ -224,7 +238,11 @@ inline T raise_pole_error(
const T& val,
const ::boost::math::policies::pole_error< ::boost::math::policies::throw_on_error>&)
{
#ifdef BOOST_NO_EXCEPTIONS
static_assert(sizeof(T) == 0, "Error handler called with throw_on_error and BOOST_NO_EXCEPTIONS set.");
#else
return boost::math::policies::detail::raise_domain_error(function, message, val, ::boost::math::policies::domain_error< ::boost::math::policies::throw_on_error>());
#endif
}

template <class T>
Expand Down Expand Up @@ -257,16 +275,19 @@ inline T raise_pole_error(
return user_pole_error(function, message, val);
}


template <class T>
inline T raise_overflow_error(
const char* function,
const char* message,
const ::boost::math::policies::overflow_error< ::boost::math::policies::throw_on_error>&)
{
#ifdef BOOST_NO_EXCEPTIONS
static_assert(sizeof(T) == 0, "Error handler called with throw_on_error and BOOST_NO_EXCEPTIONS set.");
#else
raise_error<std::overflow_error, T>(function, message ? message : "numeric overflow");
// We should never get here:
return std::numeric_limits<T>::has_infinity ? std::numeric_limits<T>::infinity() : boost::math::tools::max_value<T>();
#endif
}

template <class T>
Expand All @@ -276,9 +297,13 @@ inline T raise_overflow_error(
const T& val,
const ::boost::math::policies::overflow_error< ::boost::math::policies::throw_on_error>&)
{
#ifdef BOOST_NO_EXCEPTIONS
static_assert(sizeof(T) == 0, "Error handler called with throw_on_error and BOOST_NO_EXCEPTIONS set.");
#else
raise_error<std::overflow_error, T>(function, message ? message : "numeric overflow", val);
// We should never get here:
return std::numeric_limits<T>::has_infinity ? std::numeric_limits<T>::infinity() : boost::math::tools::max_value<T>();
#endif
}

template <class T>
Expand Down Expand Up @@ -358,9 +383,13 @@ inline T raise_underflow_error(
const char* message,
const ::boost::math::policies::underflow_error< ::boost::math::policies::throw_on_error>&)
{
#ifdef BOOST_NO_EXCEPTIONS
static_assert(sizeof(T) == 0, "Error handler called with throw_on_error and BOOST_NO_EXCEPTIONS set.");
#else
raise_error<std::underflow_error, T>(function, message ? message : "numeric underflow");
// We should never get here:
return 0;
#endif
}

template <class T>
Expand Down Expand Up @@ -402,9 +431,13 @@ inline T raise_denorm_error(
const T& /* val */,
const ::boost::math::policies::denorm_error< ::boost::math::policies::throw_on_error>&)
{
#ifdef BOOST_NO_EXCEPTIONS
static_assert(sizeof(T) == 0, "Error handler called with throw_on_error and BOOST_NO_EXCEPTIONS set.");
#else
raise_error<std::underflow_error, T>(function, message ? message : "denormalised result");
// we never get here:
return T(0);
#endif
}

template <class T>
Expand Down Expand Up @@ -449,9 +482,13 @@ inline T raise_evaluation_error(
const T& val,
const ::boost::math::policies::evaluation_error< ::boost::math::policies::throw_on_error>&)
{
#ifdef BOOST_NO_EXCEPTIONS
static_assert(sizeof(T) == 0, "Error handler called with throw_on_error and BOOST_NO_EXCEPTIONS set.");
#else
raise_error<boost::math::evaluation_error, T>(function, message, val);
// we never get here:
return T(0);
#endif
}

template <class T>
Expand Down Expand Up @@ -497,9 +534,13 @@ inline TargetType raise_rounding_error(
const TargetType&,
const ::boost::math::policies::rounding_error< ::boost::math::policies::throw_on_error>&)
{
#ifdef BOOST_NO_EXCEPTIONS
static_assert(sizeof(T) == 0, "Error handler called with throw_on_error and BOOST_NO_EXCEPTIONS set.");
#else
raise_error<boost::math::rounding_error, T>(function, message, val);
// we never get here:
return TargetType(0);
#endif
}

template <class T, class TargetType>
Expand Down Expand Up @@ -564,9 +605,13 @@ inline T raise_indeterminate_result_error(
const R& ,
const ::boost::math::policies::indeterminate_result_error< ::boost::math::policies::throw_on_error>&)
{
#ifdef BOOST_NO_EXCEPTIONS
static_assert(sizeof(T) == 0, "Error handler called with throw_on_error and BOOST_NO_EXCEPTIONS set.");
#else
raise_error<std::domain_error, T>(function, message, val);
// we never get here:
return std::numeric_limits<T>::quiet_NaN();
#endif
}

template <class T, class R>
Expand Down
3 changes: 2 additions & 1 deletion include/boost/math/special_functions/chebyshev.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <boost/math/policies/error_handling.hpp>
#include <boost/math/constants/constants.hpp>
#include <boost/math/tools/promotion.hpp>
#include <boost/math/tools/throw_exception.hpp>

#if (__cplusplus > 201103) || (defined(_CPPLIB_VER) && (_CPPLIB_VER >= 610))
# define BOOST_MATH_CHEB_USE_STD_ACOSH
Expand Down Expand Up @@ -271,7 +272,7 @@ inline Real chebyshev_clenshaw_recurrence(const Real* const c, size_t length, co
{
if (x < a || x > b)
{
throw std::domain_error("x in [a, b] is required.");
BOOST_MATH_THROW_EXCEPTION(std::domain_error("x in [a, b] is required."));
}
if (length < 2)
{
Expand Down
Loading