diff --git a/test/test_power.cpp b/test/test_power.cpp index cdf8c146a..5a4aee437 100644 --- a/test/test_power.cpp +++ b/test/test_power.cpp @@ -49,6 +49,10 @@ struct power_test void test_power_functions() { +#if defined(__clang__) && !defined(__FAST_MATH__) + // This test deliberately unmasks floating-point exceptions below. +#pragma clang fp exceptions(strict) +#endif // pow { std::transform(lhs_input.cbegin(), lhs_input.cend(), rhs_input.cbegin(), expected.begin(), diff --git a/test/test_utils.hpp b/test/test_utils.hpp index f0d64a7df..b875c3e30 100644 --- a/test/test_utils.hpp +++ b/test/test_utils.hpp @@ -152,6 +152,11 @@ namespace detail template T safe_division(const T& lhs, const T& rhs) { +#if defined(__clang__) && !defined(__FAST_MATH__) + // Comparisons also run with FE_INVALID unmasked in the power tests. + // Do not speculate a division past the zero-denominator guard. +#pragma clang fp exceptions(strict) +#endif if (rhs == T(0)) { return (std::numeric_limits::max)();