From bd18c8d9ccab18ccc5ad8bf37f0baf6183f3df45 Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Sun, 19 Jan 2025 15:19:06 +0000 Subject: [PATCH] Suppress warnings caused by use of -Wswitch_default on GCC --- .../boost/multiprecision/cpp_bin_float.hpp | 44 +++++++++++++++++++ .../boost/multiprecision/cpp_bin_float/io.hpp | 2 + .../multiprecision/detail/default_ops.hpp | 22 ++++++++++ .../multiprecision/detail/functions/pow.hpp | 4 ++ .../multiprecision/detail/functions/trig.hpp | 6 +++ 5 files changed, 78 insertions(+) diff --git a/include/boost/multiprecision/cpp_bin_float.hpp b/include/boost/multiprecision/cpp_bin_float.hpp index 3745b2c53..fdc51d978 100644 --- a/include/boost/multiprecision/cpp_bin_float.hpp +++ b/include/boost/multiprecision/cpp_bin_float.hpp @@ -416,6 +416,8 @@ class cpp_bin_float m_sign = (f < 0); m_exponent = exponent_infinity; return *this; + default: + break; } if (f < 0) { @@ -494,6 +496,8 @@ class cpp_bin_float m_sign = eval_get_sign(f) < 0; m_exponent = exponent_infinity; return *this; + default: + break; } if (eval_get_sign(f) < 0) { @@ -805,6 +809,8 @@ inline void do_eval_add(cpp_bin_float::exponent_nan: res = a; return; // result is still a NaN. + default: + break; } switch (b.exponent()) { @@ -819,6 +825,8 @@ inline void do_eval_add(cpp_bin_float::max)() - cpp_bin_float::bit_count > cpp_bin_float::max_exponent, "Exponent range check failed"); @@ -878,6 +886,8 @@ inline void do_eval_subtract(BinFloat1& res, const BinFloat2& a, const BinFloat3 case BinFloat2::exponent_nan: res = a; return; // result is still a NaN. + default: + break; } switch (b.exponent()) { @@ -892,6 +902,8 @@ inline void do_eval_subtract(BinFloat1& res, const BinFloat2& a, const BinFloat3 case BinFloat3::exponent_nan: res = b; return; // result is still a NaN. + default: + break; } bool s = a.sign(); @@ -1043,6 +1055,8 @@ inline void eval_multiply(cpp_bin_float::exponent_nan: res = a; return; + default: + break; } if (b.exponent() > cpp_bin_float::max_exponent) { @@ -1119,6 +1133,8 @@ inline typename std::enable_if::va case cpp_bin_float::exponent_nan: res = a; return; + default: + break; } typename cpp_bin_float::double_rep_type dt; @@ -1183,6 +1199,8 @@ inline void eval_divide(cpp_bin_float::exponent_nan: res = std::numeric_limits > >::quiet_NaN().backend(); return; + default: + break; } bool s = u.sign() != v.sign(); res = u; @@ -1197,6 +1215,8 @@ inline void eval_divide(cpp_bin_float::exponent_nan: res = std::numeric_limits > >::quiet_NaN().backend(); return; + default: + break; } bool s = u.sign() != v.sign(); res = u; @@ -1206,6 +1226,8 @@ inline void eval_divide(cpp_bin_float::exponent_nan: res = std::numeric_limits > >::quiet_NaN().backend(); return; + default: + break; } switch (v.exponent()) { @@ -1224,6 +1246,8 @@ inline void eval_divide(cpp_bin_float::exponent_nan: res = std::numeric_limits > >::quiet_NaN().backend(); return; + default: + break; } // We can scale u and v so that both are integers, then perform integer @@ -1368,6 +1392,8 @@ inline typename std::enable_if::va case cpp_bin_float::exponent_nan: res = std::numeric_limits > >::quiet_NaN().backend(); return; + default: + break; } if (v == 0) { @@ -1514,6 +1540,8 @@ inline void convert_to_signed_int(I* res, const cpp_bin_float::exponent_type) < sizeof(int), int, typename cpp_bin_float::exponent_type>::type; typename cpp_bin_float::rep_type man(arg.bits()); @@ -1589,6 +1617,8 @@ inline void convert_to_unsigned_int(I* res, const cpp_bin_float::exponent_infinity: *res = max_val; return; + default: + break; } typename cpp_bin_float::rep_type man(arg.bits()); using shift_type = typename std::conditional::exponent_type) < sizeof(int), int, typename cpp_bin_float::exponent_type>::type; @@ -1669,6 +1699,8 @@ inline typename std::enable_if::value>::type eval_ if (original_arg.sign()) *res = -*res; return; + default: + break; } // // Check for super large exponent that must be converted to infinity: @@ -1740,6 +1772,8 @@ inline void eval_frexp(cpp_bin_float::exponent_infinity: res = arg; return; + default: + break; } if ((e > 0) && (cpp_bin_float::max_exponent - e < arg.exponent())) { @@ -1853,6 +1889,8 @@ inline int eval_fpclassify(const cpp_bin_float::exponent_nan: return FP_NAN; + default: + break; } return FP_NORMAL; } @@ -1880,6 +1918,8 @@ inline void eval_sqrt(cpp_bin_float::exponent_infinity: res = arg; return; + default: + break; } using shift_type = typename std::conditional::exponent_type) < sizeof(int), int, typename cpp_bin_float::exponent_type>::type; shift_type shift = @@ -1969,6 +2011,8 @@ inline void eval_ceil(cpp_bin_float::exponent_nan: res = arg; return; + default: + break; } using shift_type = typename std::conditional::exponent_type) < sizeof(int), int, typename cpp_bin_float::exponent_type>::type; shift_type shift = (shift_type)cpp_bin_float::bit_count - arg.exponent() - 1; diff --git a/include/boost/multiprecision/cpp_bin_float/io.hpp b/include/boost/multiprecision/cpp_bin_float/io.hpp index 1e25d1b37..1e6b9b315 100644 --- a/include/boost/multiprecision/cpp_bin_float/io.hpp +++ b/include/boost/multiprecision/cpp_bin_float/io.hpp @@ -687,6 +687,8 @@ std::string cpp_bin_float::s case exponent_infinity: s = sign() ? "-inf" : f & std::ios_base::showpos ? "+inf" : "inf"; break; + default: + break; } } return s; diff --git a/include/boost/multiprecision/detail/default_ops.hpp b/include/boost/multiprecision/detail/default_ops.hpp index a11d17d10..bd4715b4a 100644 --- a/include/boost/multiprecision/detail/default_ops.hpp +++ b/include/boost/multiprecision/detail/default_ops.hpp @@ -1278,6 +1278,8 @@ inline BOOST_MP_CXX14_CONSTEXPR void eval_fmod(T& result, const T& a, const T& b result = std::numeric_limits >::quiet_NaN().backend(); errno = EDOM; return; + default: + break; } switch (eval_fpclassify(b)) { @@ -1286,6 +1288,8 @@ inline BOOST_MP_CXX14_CONSTEXPR void eval_fmod(T& result, const T& a, const T& b result = std::numeric_limits >::quiet_NaN().backend(); errno = EDOM; return; + default: + break; } T n; eval_divide(result, a, b); @@ -1411,6 +1415,8 @@ inline BOOST_MP_CXX14_CONSTEXPR void eval_fdim(T& result, const T& a, const T& b case FP_INFINITE: result = zero; return; + default: + break; } switch (eval_fpclassify(a)) { @@ -1420,6 +1426,8 @@ inline BOOST_MP_CXX14_CONSTEXPR void eval_fdim(T& result, const T& a, const T& b case FP_INFINITE: result = a; return; + default: + break; } if (eval_gt(a, b)) { @@ -1442,6 +1450,8 @@ inline BOOST_MP_CXX14_CONSTEXPR typename std::enable_if >::infinity().backend(); return; + default: + break; } if (eval_gt(canonical_a, b)) { @@ -1504,6 +1520,8 @@ inline BOOST_MP_CXX14_CONSTEXPR void eval_trunc(T& result, const T& a) case FP_INFINITE: result = a; return; + default: + break; } if (eval_get_sign(a) < 0) eval_ceil(result, a); @@ -1920,6 +1938,8 @@ inline BOOST_MP_CXX14_CONSTEXPR typename B::exponent_type eval_ilogb(const B& va return (std::numeric_limits::max)(); case FP_ZERO: return (std::numeric_limits::min)(); + default: + break; } B result; eval_frexp(result, val, &e); @@ -1945,6 +1965,8 @@ inline BOOST_MP_CXX14_CONSTEXPR void eval_logb(B& result, const B& val) if (eval_signbit(val)) result.negate(); return; + default: + break; } using max_t = typename std::conditional::value, long long, std::intmax_t>::type; result = static_cast(eval_ilogb(val)); diff --git a/include/boost/multiprecision/detail/functions/pow.hpp b/include/boost/multiprecision/detail/functions/pow.hpp index 4338650b1..34f4febf5 100644 --- a/include/boost/multiprecision/detail/functions/pow.hpp +++ b/include/boost/multiprecision/detail/functions/pow.hpp @@ -62,6 +62,8 @@ inline void pow_imp(T& result, const T& t, const U& p, const std::integral_const eval_multiply(result, t, t); eval_multiply(result, result); return; + default: + break; } // This will store the result. @@ -392,6 +394,8 @@ void eval_log(T& result, const T& arg) result.negate(); errno = ERANGE; return; + default: + break; } if (s) { diff --git a/include/boost/multiprecision/detail/functions/trig.hpp b/include/boost/multiprecision/detail/functions/trig.hpp index 56476c551..02442a2f5 100644 --- a/include/boost/multiprecision/detail/functions/trig.hpp +++ b/include/boost/multiprecision/detail/functions/trig.hpp @@ -716,6 +716,8 @@ inline void eval_acos(T& result, const T& x) result = get_constant_pi(); eval_ldexp(result, result, -1); // divide by two. return; + default: + break; } T xx; @@ -986,6 +988,8 @@ void eval_atan2(T& result, const T& y, const T& x) } return; } + default: + break; } switch (eval_fpclassify(x)) @@ -1009,6 +1013,8 @@ void eval_atan2(T& result, const T& y, const T& x) if (eval_get_sign(y) < 0) result.negate(); return; + default: + break; } T xx;