diff --git a/include/boost/decimal/cstdio.hpp b/include/boost/decimal/cstdio.hpp index 8f0d4753d..addb47112 100644 --- a/include/boost/decimal/cstdio.hpp +++ b/include/boost/decimal/cstdio.hpp @@ -43,6 +43,12 @@ enum class decimal_type : unsigned decimal128_t = 1 << 2 }; +// Internal use only +#ifdef __GNUC__ +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wpadded" +#endif + struct parameters { int precision; @@ -51,6 +57,10 @@ struct parameters bool upper_case; }; +#ifdef __GNUC__ +# pragma GCC diagnostic pop +#endif + inline auto parse_format(const char* format) -> parameters { // If the format is unspecified or incorrect, we will use this as the default values @@ -154,6 +164,12 @@ inline void make_uppercase(char* first, const char* last) noexcept } } +// Cast of return value avoids warning when sizeof(std::ptrdiff_t) > sizeof(int) e.g. when not in 32-bit +#if defined(__GNUC__) && defined(__i386__) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wuseless-cast" +#endif + template inline auto snprintf_impl(char* buffer, const std::size_t buf_size, const char* format, const T... values) noexcept #ifndef BOOST_DECIMAL_HAS_CONCEPTS @@ -240,6 +256,10 @@ inline auto snprintf_impl(char* buffer, const std::size_t buf_size, const char* return static_cast(buffer - buffer_begin); } +#if defined(__GNUC__) && defined(__i386__) +# pragma GCC diagnostic pop +#endif + } // namespace detail template diff --git a/include/boost/decimal/decimal128_t.hpp b/include/boost/decimal/decimal128_t.hpp index dba59a6de..c99987252 100644 --- a/include/boost/decimal/decimal128_t.hpp +++ b/include/boost/decimal/decimal128_t.hpp @@ -1691,7 +1691,7 @@ constexpr auto d128_mod_impl(const decimal128_t& lhs, const decimal128_t& rhs, c constexpr decimal128_t zero {0, 0}; auto q_trunc {q > zero ? floor(q) : ceil(q)}; - r = lhs - (decimal128_t(q_trunc) * rhs); + r = lhs - (q_trunc * rhs); } constexpr auto operator+(const decimal128_t& lhs, const decimal128_t& rhs) noexcept -> decimal128_t diff --git a/include/boost/decimal/decimal32_t.hpp b/include/boost/decimal/decimal32_t.hpp index 565a4a5e1..577ec4546 100644 --- a/include/boost/decimal/decimal32_t.hpp +++ b/include/boost/decimal/decimal32_t.hpp @@ -2007,7 +2007,7 @@ constexpr auto mod_impl(const decimal32_t lhs, const decimal32_t rhs, const deci // https://en.cppreference.com/w/cpp/numeric/math/fmod auto q_trunc {q > zero ? floor(q) : ceil(q)}; - r = lhs - (decimal32_t(q_trunc) * rhs); + r = lhs - (q_trunc * rhs); } constexpr auto operator/(const decimal32_t lhs, const decimal32_t rhs) noexcept -> decimal32_t diff --git a/include/boost/decimal/decimal64_t.hpp b/include/boost/decimal/decimal64_t.hpp index 335f9e3f8..287e2d6ef 100644 --- a/include/boost/decimal/decimal64_t.hpp +++ b/include/boost/decimal/decimal64_t.hpp @@ -1672,7 +1672,7 @@ constexpr auto d64_mod_impl(const decimal64_t lhs, const decimal64_t rhs, const // https://en.cppreference.com/w/cpp/numeric/math/fmod auto q_trunc {q > zero ? floor(q) : ceil(q)}; - r = lhs - (decimal64_t(q_trunc) * rhs); + r = lhs - (q_trunc * rhs); } constexpr auto operator+(const decimal64_t lhs, const decimal64_t rhs) noexcept -> decimal64_t diff --git a/include/boost/decimal/decimal_fast128_t.hpp b/include/boost/decimal/decimal_fast128_t.hpp index a1c861494..2903da964 100644 --- a/include/boost/decimal/decimal_fast128_t.hpp +++ b/include/boost/decimal/decimal_fast128_t.hpp @@ -85,7 +85,7 @@ constexpr auto write_payload(typename TargetDecimalType::significand_type payloa # pragma warning(disable : 4324) // Structure was padded due to alignment specifier #endif -BOOST_DECIMAL_EXPORT class decimal_fast128_t final +BOOST_DECIMAL_EXPORT class alignas(16) decimal_fast128_t final { public: using significand_type = int128::uint128_t; @@ -99,6 +99,7 @@ BOOST_DECIMAL_EXPORT class decimal_fast128_t final significand_type significand_ {}; exponent_type exponent_ {}; bool sign_ {}; + char pad_[11] {}; constexpr auto isneg() const noexcept -> bool { @@ -1035,7 +1036,7 @@ constexpr auto operator+(const decimal_fast128_t& lhs, const decimal_fast128_t& lhs.significand_, lhs.biased_exponent(), lhs.sign_, rhs.significand_, rhs.biased_exponent(), rhs.sign_, (abs(lhs) > abs(rhs))); -}; +} template constexpr auto operator+(const decimal_fast128_t& lhs, const Integer rhs) noexcept @@ -1304,8 +1305,8 @@ constexpr auto d128f_mod_impl(const decimal_fast128_t& lhs, const decimal_fast12 constexpr decimal_fast128_t zero {0, 0}; auto q_trunc {q > zero ? floor(q) : ceil(q)}; - r = lhs - (decimal_fast128_t(q_trunc) * rhs); -}; + r = lhs - (q_trunc * rhs); +} constexpr auto operator/(const decimal_fast128_t& lhs, const decimal_fast128_t& rhs) noexcept -> decimal_fast128_t { @@ -1314,7 +1315,7 @@ constexpr auto operator/(const decimal_fast128_t& lhs, const decimal_fast128_t& d128f_div_impl(lhs, rhs, q, r); return q; -}; +} template constexpr auto operator/(const decimal_fast128_t& lhs, const Integer rhs) noexcept @@ -1405,7 +1406,7 @@ constexpr auto operator%(const decimal_fast128_t& lhs, const decimal_fast128_t& } return r; -}; +} constexpr auto decimal_fast128_t::operator+=(const decimal_fast128_t& rhs) noexcept -> decimal_fast128_t& { diff --git a/include/boost/decimal/decimal_fast32_t.hpp b/include/boost/decimal/decimal_fast32_t.hpp index 98041fc74..bd159dbe5 100644 --- a/include/boost/decimal/decimal_fast32_t.hpp +++ b/include/boost/decimal/decimal_fast32_t.hpp @@ -78,7 +78,12 @@ constexpr auto write_payload(typename TargetDecimalType::significand_type payloa } // namespace detail -BOOST_DECIMAL_EXPORT class decimal_fast32_t final +#ifdef _MSC_VER +# pragma warning(push) +# pragma warning(disable : 4324) // Structure was padded due to alignment specifier +#endif + +BOOST_DECIMAL_EXPORT class alignas(4) decimal_fast32_t final { public: using significand_type = std::uint32_t; @@ -93,6 +98,7 @@ BOOST_DECIMAL_EXPORT class decimal_fast32_t final significand_type significand_ {}; exponent_type exponent_ {}; bool sign_ {}; + char pad_[2] {}; constexpr auto isneg() const noexcept -> bool { @@ -495,6 +501,10 @@ BOOST_DECIMAL_EXPORT class decimal_fast32_t final friend constexpr auto quantized32f(decimal_fast32_t lhs, decimal_fast32_t rhs) noexcept -> decimal_fast32_t; }; +#ifdef _MSC_VER +# pragma warning(pop) +#endif + template && detail::is_integral_v, bool>> constexpr decimal_fast32_t::decimal_fast32_t(T1 coeff, T2 exp, const detail::construction_sign_wrapper resultant_sign) noexcept { @@ -1259,7 +1269,7 @@ constexpr auto mod_impl(const decimal_fast32_t lhs, const decimal_fast32_t rhs, // https://en.cppreference.com/w/cpp/numeric/math/fmod auto q_trunc {q > zero ? floor(q) : ceil(q)}; - r = lhs - (decimal_fast32_t(q_trunc) * rhs); + r = lhs - (q_trunc * rhs); } constexpr auto operator/(const decimal_fast32_t lhs, const decimal_fast32_t rhs) noexcept -> decimal_fast32_t diff --git a/include/boost/decimal/decimal_fast64_t.hpp b/include/boost/decimal/decimal_fast64_t.hpp index cd5d516a8..23aa5efa6 100644 --- a/include/boost/decimal/decimal_fast64_t.hpp +++ b/include/boost/decimal/decimal_fast64_t.hpp @@ -80,7 +80,12 @@ constexpr auto write_payload(typename TargetDecimalType::significand_type payloa } // namespace detail -BOOST_DECIMAL_EXPORT class decimal_fast64_t final +#ifdef _MSC_VER +# pragma warning(push) +# pragma warning(disable : 4324) // Structure was padded due to alignment specifier +#endif + +BOOST_DECIMAL_EXPORT class alignas(8) decimal_fast64_t final { public: using significand_type = std::uint64_t; @@ -94,6 +99,7 @@ BOOST_DECIMAL_EXPORT class decimal_fast64_t final significand_type significand_ {}; exponent_type exponent_ {}; bool sign_ {}; + char pad_[5] {}; constexpr auto isneg() const noexcept -> bool { @@ -496,6 +502,10 @@ BOOST_DECIMAL_EXPORT class decimal_fast64_t final friend constexpr auto quantexpd64f(decimal_fast64_t x) noexcept -> int; }; +#ifdef _MSC_VER +# pragma warning(pop) +#endif + #ifdef BOOST_DECIMAL_HAS_CONCEPTS template #else @@ -1402,7 +1412,7 @@ constexpr auto d64_fast_mod_impl(const decimal_fast64_t lhs, const decimal_fast6 // https://en.cppreference.com/w/cpp/numeric/math/fmod auto q_trunc {q > zero ? floor(q) : ceil(q)}; - r = lhs - (decimal_fast64_t(q_trunc) * rhs); + r = lhs - (q_trunc * rhs); } constexpr auto operator/(const decimal_fast64_t& lhs, const decimal_fast64_t& rhs) noexcept -> decimal_fast64_t diff --git a/include/boost/decimal/detail/cmath/atan.hpp b/include/boost/decimal/detail/cmath/atan.hpp index 28246eb78..f9581f948 100644 --- a/include/boost/decimal/detail/cmath/atan.hpp +++ b/include/boost/decimal/detail/cmath/atan.hpp @@ -84,7 +84,7 @@ constexpr auto atan_impl(const T x) noexcept if(!is_smallish) { - constexpr T my_pi_over_six { numbers::pi_v / static_cast(INT8_C(6)) }; + constexpr T my_pi_over_six { numbers::pi_v / 6 }; result += my_pi_over_six; } diff --git a/include/boost/decimal/detail/cmath/cos.hpp b/include/boost/decimal/detail/cmath/cos.hpp index bcea6d4db..40aad502b 100644 --- a/include/boost/decimal/detail/cmath/cos.hpp +++ b/include/boost/decimal/detail/cmath/cos.hpp @@ -65,7 +65,7 @@ constexpr auto cos_impl(const T x) noexcept const T two_x = x * 2; const auto k = static_cast(two_x / numbers::pi_v); - const auto n = static_cast(k % static_cast(UINT8_C(4))); + const auto n = k % static_cast(UINT8_C(4)); const T two_r { two_x - (numbers::pi_v * k) }; diff --git a/include/boost/decimal/detail/cmath/exp.hpp b/include/boost/decimal/detail/cmath/exp.hpp index 777cc6251..34429ebe6 100644 --- a/include/boost/decimal/detail/cmath/exp.hpp +++ b/include/boost/decimal/detail/cmath/exp.hpp @@ -77,7 +77,7 @@ constexpr auto exp_impl(T x) noexcept { if (nf2 < 64) { - result *= T { static_cast(UINT64_C(1) << static_cast(nf2)), 0 }; + result *= T { UINT64_C(1) << static_cast(nf2), 0 }; } else { diff --git a/include/boost/decimal/detail/cmath/frexp.hpp b/include/boost/decimal/detail/cmath/frexp.hpp index cb9a29401..a95833281 100644 --- a/include/boost/decimal/detail/cmath/frexp.hpp +++ b/include/boost/decimal/detail/cmath/frexp.hpp @@ -57,15 +57,7 @@ constexpr auto frexp_impl(const T v, int* expon) noexcept if(b_neg) { result_frexp = -result_frexp; } - auto t = - static_cast - ( - static_cast - ( - static_cast(ilogb(result_frexp) - detail::bias) * INT32_C(1000) - ) - / INT32_C(301) - ); + auto t = static_cast(ilogb(result_frexp) - detail::bias) * INT32_C(1000) / 301; result_frexp *= detail::pow_2_impl(-t); diff --git a/include/boost/decimal/detail/cmath/ilogb.hpp b/include/boost/decimal/detail/cmath/ilogb.hpp index b2e972840..b11ca8206 100644 --- a/include/boost/decimal/detail/cmath/ilogb.hpp +++ b/include/boost/decimal/detail/cmath/ilogb.hpp @@ -28,16 +28,16 @@ constexpr auto ilogb(const T d) noexcept if (fpc == FP_ZERO) { - result = static_cast(FP_ILOGB0); + result = FP_ILOGB0; } #ifndef BOOST_DECIMAL_FAST_MATH else if (fpc == FP_INFINITE) { - result = static_cast(INT_MAX); + result = INT_MAX; } else if (fpc == FP_NAN) { - result = static_cast(FP_ILOGBNAN); + result = FP_ILOGBNAN; } #endif else diff --git a/include/boost/decimal/detail/cmath/impl/assoc_legendre_lookup.hpp b/include/boost/decimal/detail/cmath/impl/assoc_legendre_lookup.hpp index 17b8e9d8a..4a35f4c47 100644 --- a/include/boost/decimal/detail/cmath/impl/assoc_legendre_lookup.hpp +++ b/include/boost/decimal/detail/cmath/impl/assoc_legendre_lookup.hpp @@ -682,37 +682,37 @@ constexpr auto assoc_legendre_p0_lookup(unsigned n) -> T; template <> constexpr auto assoc_legendre_p0_lookup(unsigned n) -> decimal32_t { - return assoc_legendre_detail::assoc_legendre_lookup_table::d32_values[static_cast(n)]; + return assoc_legendre_detail::assoc_legendre_lookup_table::d32_values[n]; } template <> constexpr auto assoc_legendre_p0_lookup(unsigned n) -> decimal_fast32_t { - return assoc_legendre_detail::assoc_legendre_lookup_table::d32_fast_values[static_cast(n)]; + return assoc_legendre_detail::assoc_legendre_lookup_table::d32_fast_values[n]; } template <> constexpr auto assoc_legendre_p0_lookup(unsigned n) -> decimal64_t { - return assoc_legendre_detail::assoc_legendre_lookup_table::d64_values[static_cast(n)]; + return assoc_legendre_detail::assoc_legendre_lookup_table::d64_values[n]; } template <> constexpr auto assoc_legendre_p0_lookup(unsigned n) -> decimal_fast64_t { - return assoc_legendre_detail::assoc_legendre_lookup_table::d64_fast_values[static_cast(n)]; + return assoc_legendre_detail::assoc_legendre_lookup_table::d64_fast_values[n]; } template <> constexpr auto assoc_legendre_p0_lookup(unsigned n) -> decimal128_t { - return assoc_legendre_detail::assoc_legendre_lookup_table::d128_values[static_cast(n)]; + return assoc_legendre_detail::assoc_legendre_lookup_table::d128_values[n]; } template <> constexpr auto assoc_legendre_p0_lookup(unsigned n) -> decimal_fast128_t { - return assoc_legendre_detail::assoc_legendre_lookup_table::d128_fast_values[static_cast(n)]; + return assoc_legendre_detail::assoc_legendre_lookup_table::d128_fast_values[n]; } } //namespace detail diff --git a/include/boost/decimal/detail/cmath/impl/ellint_impl.hpp b/include/boost/decimal/detail/cmath/impl/ellint_impl.hpp index 5d168e2fd..b86584311 100644 --- a/include/boost/decimal/detail/cmath/impl/ellint_impl.hpp +++ b/include/boost/decimal/detail/cmath/impl/ellint_impl.hpp @@ -135,7 +135,7 @@ constexpr auto agm(T phi, } } - p2 = static_cast(p2 << 1U); + p2 = p2 << 1U; if(fabs(cn_term) < break_check) { diff --git a/include/boost/decimal/detail/cmath/impl/pow_impl.hpp b/include/boost/decimal/detail/cmath/impl/pow_impl.hpp index 30a1700e9..8a066792a 100644 --- a/include/boost/decimal/detail/cmath/impl/pow_impl.hpp +++ b/include/boost/decimal/detail/cmath/impl/pow_impl.hpp @@ -86,7 +86,7 @@ constexpr auto pow_2_impl(int e2) noexcept -> std::enable_if_t(UINT64_C(1) << e2), 0 }; + result = T { UINT64_C(1) << e2, 0 }; } else { @@ -97,11 +97,11 @@ constexpr auto pow_2_impl(int e2) noexcept -> std::enable_if_t(static_cast(~e2) + 1U); + const auto e2_neg = static_cast(~e2) + 1U; if(e2 > -64) { - const T local_p2 { static_cast(UINT64_C(1) << e2_neg), 0 }; + const T local_p2 { UINT64_C(1) << e2_neg, 0 }; result = one / local_p2; } diff --git a/include/boost/decimal/detail/cmath/impl/riemann_zeta_impl.hpp b/include/boost/decimal/detail/cmath/impl/riemann_zeta_impl.hpp index 040ce979c..91599f1fd 100644 --- a/include/boost/decimal/detail/cmath/impl/riemann_zeta_impl.hpp +++ b/include/boost/decimal/detail/cmath/impl/riemann_zeta_impl.hpp @@ -354,7 +354,7 @@ constexpr auto riemann_zeta_decimal_order(T x) noexcept : 33 }; - return static_cast(n + order_bias); + return n + order_bias; } template diff --git a/include/boost/decimal/detail/cmath/pow.hpp b/include/boost/decimal/detail/cmath/pow.hpp index 13fd14874..0dc3f8f98 100644 --- a/include/boost/decimal/detail/cmath/pow.hpp +++ b/include/boost/decimal/detail/cmath/pow.hpp @@ -114,7 +114,7 @@ constexpr auto pow(const T b, const IntegralType p) noexcept // Here, a pure power-of-10 argument (b) gets a pure integral result. const int log10_val { exp10val + static_cast(zeros_removal.number_of_removed_zeros) }; - result = T { 1, static_cast(log10_val * static_cast(p)) }; + result = T { 1, log10_val * static_cast(p) }; } else { diff --git a/include/boost/decimal/detail/cmath/sin.hpp b/include/boost/decimal/detail/cmath/sin.hpp index 07000f97c..035447241 100644 --- a/include/boost/decimal/detail/cmath/sin.hpp +++ b/include/boost/decimal/detail/cmath/sin.hpp @@ -49,7 +49,7 @@ constexpr auto sin_impl(const T x) noexcept } else { - if(x > static_cast(INT8_C(0))) + if(x > 0) { // Perform argument reduction and subsequent scaling of the result. @@ -65,7 +65,7 @@ constexpr auto sin_impl(const T x) noexcept const T two_x = x * 2; const auto k = static_cast(two_x / numbers::pi_v); - const auto n = static_cast(k % static_cast(UINT8_C(4))); + const auto n = k % static_cast(4); const T two_r { two_x - (numbers::pi_v * k) }; diff --git a/include/boost/decimal/detail/cmath/tan.hpp b/include/boost/decimal/detail/cmath/tan.hpp index 24b00bde8..bcb32d657 100644 --- a/include/boost/decimal/detail/cmath/tan.hpp +++ b/include/boost/decimal/detail/cmath/tan.hpp @@ -70,7 +70,7 @@ constexpr auto tan_impl(const T x) noexcept const T two_x = x * 2; const auto k = static_cast(two_x / numbers::pi_v); - const auto n = static_cast(k % static_cast(UINT8_C(4))); + const auto n = k % static_cast(UINT8_C(4)); const T two_r { two_x - (numbers::pi_v * k) }; diff --git a/include/boost/decimal/detail/components.hpp b/include/boost/decimal/detail/components.hpp index 4b5a7f35e..f7d2eb7e2 100644 --- a/include/boost/decimal/detail/components.hpp +++ b/include/boost/decimal/detail/components.hpp @@ -23,6 +23,13 @@ namespace impl { # pragma warning(disable : 4324) // Structure was padded due to alignment specifier #endif + +// Internal use only, and changes based on the types +#ifdef __GNUC__ +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wpadded" +#endif + template struct decimal_components { @@ -74,6 +81,10 @@ using decimal128_t_components = impl::decimal_components; +#ifdef __GNUC__ +# pragma GCC diagnostic pop +#endif + #ifdef _MSC_VER # pragma warning(pop) #endif diff --git a/include/boost/decimal/detail/fenv_rounding.hpp b/include/boost/decimal/detail/fenv_rounding.hpp index 724d7a7e6..61ac9aa48 100644 --- a/include/boost/decimal/detail/fenv_rounding.hpp +++ b/include/boost/decimal/detail/fenv_rounding.hpp @@ -19,6 +19,12 @@ namespace detail { namespace impl { +// These structs are for internal use only and change based on the type of T +#ifdef __GNUC__ +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wpadded" +#endif + template struct divmod_result { @@ -33,6 +39,10 @@ struct divmod10_result std::uint64_t remainder; }; +#ifdef __GNUC__ +# pragma GCC diagnostic pop +#endif + template ::value, bool> = true> constexpr auto divmod(T dividend, T divisor) noexcept -> divmod_result { diff --git a/include/boost/decimal/detail/from_chars_result.hpp b/include/boost/decimal/detail/from_chars_result.hpp index 421710eb2..bdb8ac6e4 100644 --- a/include/boost/decimal/detail/from_chars_result.hpp +++ b/include/boost/decimal/detail/from_chars_result.hpp @@ -18,6 +18,12 @@ namespace decimal { // 22.13.3, Primitive numerical input conversion +// This is how the STL says to implement +#ifdef __GNUC__ +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wpadded" +#endif + BOOST_DECIMAL_EXPORT struct from_chars_result { const char* ptr; @@ -41,6 +47,10 @@ BOOST_DECIMAL_EXPORT struct from_chars_result constexpr explicit operator bool() const noexcept { return ec == std::errc{}; } }; +#ifdef __GNUC__ +# pragma GCC diagnostic pop +#endif + } // namespace decimal } // namespace boost diff --git a/include/boost/decimal/detail/int128/cstdlib.hpp b/include/boost/decimal/detail/int128/cstdlib.hpp index 3ecf321f6..00de6f2f8 100644 --- a/include/boost/decimal/detail/int128/cstdlib.hpp +++ b/include/boost/decimal/detail/int128/cstdlib.hpp @@ -82,9 +82,9 @@ constexpr i128div_t div(const int128_t x, const int128_t y) noexcept const auto negative_quot {(x.high < 0) != (y.high < 0)}; #if defined(_MSC_VER) && !defined(__GNUC__) - const auto negative_rem {static_cast(x.high < 0)}; + const auto negative_rem {x.high < 0}; #else - const auto negative_rem {static_cast((x.high < 0) != (y.high < 0))}; + const auto negative_rem {(x.high < 0) != (y.high < 0)}; #endif i128div_t res {static_cast(unsigned_res.quot), static_cast(unsigned_res.rem)}; diff --git a/include/boost/decimal/detail/int128/detail/int128_imp.hpp b/include/boost/decimal/detail/int128/detail/int128_imp.hpp index 57dffc21e..3c1796fca 100644 --- a/include/boost/decimal/detail/int128/detail/int128_imp.hpp +++ b/include/boost/decimal/detail/int128/detail/int128_imp.hpp @@ -3071,9 +3071,9 @@ constexpr int128_t operator%(const int128_t lhs, const int128_t rhs) noexcept #else #if defined(_MSC_VER) && !defined(__GNUC__) - const auto is_neg{static_cast(lhs < 0)}; + const auto is_neg{lhs < 0}; #else - const auto is_neg {static_cast((lhs < 0) != (rhs < 0))}; + const auto is_neg {(lhs < 0) != (rhs < 0)}; #endif int128_t remainder {}; diff --git a/include/boost/decimal/detail/locale_conversion.hpp b/include/boost/decimal/detail/locale_conversion.hpp index 88df2e2c6..1c2d9c51e 100644 --- a/include/boost/decimal/detail/locale_conversion.hpp +++ b/include/boost/decimal/detail/locale_conversion.hpp @@ -87,6 +87,12 @@ inline void convert_string_to_c_locale(char* buffer) noexcept convert_string_to_c_locale(buffer, std::locale()); } +// Cast of return value avoids warning when sizeof(std::ptrdiff_t) > sizeof(int) e.g. when not in 32-bit +#if defined(__GNUC__) && defined(__i386__) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wuseless-cast" +#endif + inline int convert_pointer_pair_to_local_locale(char* first, const char* last, const std::locale& loc) noexcept { const std::numpunct& np = std::use_facet>(loc); @@ -128,7 +134,7 @@ inline int convert_pointer_pair_to_local_locale(char* first, const char* last, c // Determine the end of the integer part const auto int_end {decimal_pos != nullptr ? decimal_pos : string_end}; - const auto int_digits {static_cast(int_end - start)}; + const auto int_digits {(int_end - start)}; // Calculate how many separators we need int num_separators {}; @@ -136,14 +142,14 @@ inline int convert_pointer_pair_to_local_locale(char* first, const char* last, c { if (int_digits > grouping_size) { - num_separators = (int_digits - 1) / grouping_size; + num_separators = static_cast((int_digits - 1) / grouping_size); } } // If we need to add separators, shift content and insert them if (num_separators > 0) { - const auto original_length {static_cast(string_end - first)}; + const auto original_length {(string_end - first)}; const auto new_length {original_length + num_separators}; // Check if we have enough space in the buffer @@ -186,6 +192,11 @@ inline int convert_pointer_pair_to_local_locale(char* first, const char* last, c return num_separators; } +// Cast of return value avoids warning when sizeof(std::ptrdiff_t) > sizeof(int) e.g. when not in 32-bit +#if defined(__GNUC__) && defined(__i386__) +# pragma GCC diagnostic pop +#endif + #if defined(__GNUC__) && __GNUC__ == 9 # pragma GCC diagnostic pop #elif defined(__clang__) && __clang_major__ == 12 diff --git a/include/boost/decimal/detail/memcpy.hpp b/include/boost/decimal/detail/memcpy.hpp index 0161bf111..05f2e3113 100644 --- a/include/boost/decimal/detail/memcpy.hpp +++ b/include/boost/decimal/detail/memcpy.hpp @@ -83,7 +83,7 @@ constexpr char* memcpy(char* dest, const char* src, std::size_t count) { if (BOOST_DECIMAL_IS_CONSTANT_EVALUATED(count)) { - return static_cast(impl::memcpy_impl(dest, src, count)); + return impl::memcpy_impl(dest, src, count); } else { @@ -107,7 +107,7 @@ constexpr char* memset(char* dest, int ch, std::size_t count) { if (BOOST_DECIMAL_IS_CONSTANT_EVALUATED(count)) { - return static_cast(impl::memset_impl(dest, ch, count)); + return impl::memset_impl(dest, ch, count); } else { @@ -119,7 +119,7 @@ constexpr char* memmove(char* dest, const char* src, std::size_t count) { if (BOOST_DECIMAL_IS_CONSTANT_EVALUATED(count)) { - return static_cast(impl::memmove_impl(dest, src, count)); + return impl::memmove_impl(dest, src, count); } else { diff --git a/include/boost/decimal/detail/remove_trailing_zeros.hpp b/include/boost/decimal/detail/remove_trailing_zeros.hpp index 0cf1e93c1..66e71d357 100644 --- a/include/boost/decimal/detail/remove_trailing_zeros.hpp +++ b/include/boost/decimal/detail/remove_trailing_zeros.hpp @@ -29,6 +29,12 @@ constexpr auto rotr(UInt n, unsigned int r) noexcept return (n >> r) | (n << ((bit_width - r) & (bit_width - 1))); } +// For internal use only and changes based on the type of T +#ifdef __GNUC__ +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wpadded" +#endif + template struct remove_trailing_zeros_return { @@ -36,6 +42,10 @@ struct remove_trailing_zeros_return std::size_t number_of_removed_zeros; }; +#ifdef __GNUC__ +# pragma GCC diagnostic pop +#endif + constexpr auto remove_trailing_zeros(std::uint32_t n) noexcept -> remove_trailing_zeros_return { std::size_t s {}; diff --git a/include/boost/decimal/detail/ryu/ryu_generic_128.hpp b/include/boost/decimal/detail/ryu/ryu_generic_128.hpp index db0e3d6ee..1e1cefa93 100644 --- a/include/boost/decimal/detail/ryu/ryu_generic_128.hpp +++ b/include/boost/decimal/detail/ryu/ryu_generic_128.hpp @@ -36,6 +36,12 @@ BOOST_DECIMAL_INLINE_CONSTEXPR_VARIABLE unsigned_128_type one = 1; # pragma warning(disable : 4324) // Structure was padded due to alignment specifier #endif +// Internal use only +#ifdef __GNUC__ +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wpadded" +#endif + struct floating_decimal_128 { unsigned_128_type mantissa; @@ -43,6 +49,10 @@ struct floating_decimal_128 bool sign; }; +#ifdef __GNUC__ +# pragma GCC diagnostic pop +#endif + #ifdef _MSC_VER # pragma warning(pop) #endif diff --git a/include/boost/decimal/detail/to_chars_integer_impl.hpp b/include/boost/decimal/detail/to_chars_integer_impl.hpp index 4923a8d0c..adc66550b 100644 --- a/include/boost/decimal/detail/to_chars_integer_impl.hpp +++ b/include/boost/decimal/detail/to_chars_integer_impl.hpp @@ -127,7 +127,7 @@ constexpr char* decompose32(std::uint32_t value, char* buffer) noexcept for (std::size_t i {}; i < 10; i += 2) { - boost::decimal::detail::memcpy(buffer + i, radix_table + static_cast(y >> 57) * 2, 2); + boost::decimal::detail::memcpy(buffer + i, radix_table + (y >> 57) * 2, 2); y &= mask; y *= 100U; } @@ -295,7 +295,7 @@ constexpr to_chars_result to_chars_integer_impl(char* first, char* last, Integer unsigned_value = static_cast(value); } - auto converted_value = static_cast(unsigned_value); + auto converted_value = unsigned_value; const int converted_value_digits = num_digits(converted_value); diff --git a/include/boost/decimal/detail/to_chars_result.hpp b/include/boost/decimal/detail/to_chars_result.hpp index 955a9dfed..7c43a0e73 100644 --- a/include/boost/decimal/detail/to_chars_result.hpp +++ b/include/boost/decimal/detail/to_chars_result.hpp @@ -16,6 +16,12 @@ namespace boost { namespace decimal { +// This is how the STL says to implement +#ifdef __GNUC__ +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wpadded" +#endif + BOOST_DECIMAL_EXPORT struct to_chars_result { char *ptr; @@ -34,6 +40,10 @@ BOOST_DECIMAL_EXPORT struct to_chars_result constexpr explicit operator bool() const noexcept { return ec == std::errc{}; } }; +#ifdef __GNUC__ +# pragma GCC diagnostic pop +#endif + } // namespace decimal } // namespace boost diff --git a/test/Jamfile b/test/Jamfile index b7b73bb76..4d353e375 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -29,6 +29,11 @@ project : requirements #gcc:-Wduplicated-branches gcc:-Wfloat-equal gcc:-Wshadow + # https://github.com/cppalliance/decimal/issues/1291 + # GCC-7 does not support extra-semi, just pick one to try + gcc-13:-Wextra-semi + gcc:-Wuseless-cast + # gcc:-Wpadded clang:-Wsign-conversion clang:-Wconversion diff --git a/test/compare_dec128_and_fast.cpp b/test/compare_dec128_and_fast.cpp index 87ab7b765..7f74c9358 100644 --- a/test/compare_dec128_and_fast.cpp +++ b/test/compare_dec128_and_fast.cpp @@ -24,9 +24,9 @@ using namespace boost::decimal; #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) -static constexpr auto N = static_cast(128U); // Number of trials +static constexpr auto N = static_cast(128); // Number of trials #else -static constexpr auto N = static_cast(8U); // Number of trials +static constexpr auto N = static_cast(8); // Number of trials #endif static std::mt19937_64 rng(42); diff --git a/test/random_decimal128_comp.cpp b/test/random_decimal128_comp.cpp index b7da3b090..91fb8e8a0 100644 --- a/test/random_decimal128_comp.cpp +++ b/test/random_decimal128_comp.cpp @@ -11,9 +11,9 @@ using namespace boost::decimal; #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) -static constexpr auto N = static_cast(1024U); // Number of trials +static constexpr auto N = static_cast(1024); // Number of trials #else -static constexpr auto N = static_cast(1024U >> 4U); // Number of trials +static constexpr auto N = static_cast(1024 >> 4U); // Number of trials #endif // NOLINTNEXTLINE : Seed with a constant for repeatability diff --git a/test/random_decimal128_fast_comp.cpp b/test/random_decimal128_fast_comp.cpp index 48f26e425..fd3acc882 100644 --- a/test/random_decimal128_fast_comp.cpp +++ b/test/random_decimal128_fast_comp.cpp @@ -11,9 +11,9 @@ using namespace boost::decimal; #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) -static constexpr auto N = static_cast(1024U); // Number of trials +static constexpr auto N = static_cast(1024); // Number of trials #else -static constexpr auto N = static_cast(1024U >> 4U); // Number of trials +static constexpr auto N = static_cast(1024 >> 4U); // Number of trials #endif // NOLINTNEXTLINE : Seed with a constant for repeatability diff --git a/test/random_decimal128_fast_math.cpp b/test/random_decimal128_fast_math.cpp index 49dc8d7ce..ae7d9a44c 100644 --- a/test/random_decimal128_fast_math.cpp +++ b/test/random_decimal128_fast_math.cpp @@ -21,9 +21,9 @@ using namespace boost::decimal; #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) -static constexpr auto N = static_cast(1024U); // Number of trials +static constexpr auto N = static_cast(1024); // Number of trials #else -static constexpr auto N = static_cast(1024U >> 4U); // Number of trials +static constexpr auto N = static_cast(1024 >> 4U); // Number of trials #endif static std::mt19937_64 rng(42); @@ -330,7 +330,7 @@ void spot_check_mul(T val1, T val2) << "\nInt res: " << decimal_fast128_t{val1 * val2} << std::endl; // LCOV_EXCL_STOP } -}; +} template void random_division(T lower, T upper) diff --git a/test/random_decimal128_math.cpp b/test/random_decimal128_math.cpp index 913a67641..2dd0add32 100644 --- a/test/random_decimal128_math.cpp +++ b/test/random_decimal128_math.cpp @@ -21,9 +21,9 @@ using namespace boost::decimal; #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) -static constexpr auto N = static_cast(128U); // Number of trials +static constexpr auto N = static_cast(128); // Number of trials #else -static constexpr auto N = static_cast(8U); // Number of trials +static constexpr auto N = static_cast(8); // Number of trials #endif static std::mt19937_64 rng(42); diff --git a/test/random_decimal32_comp.cpp b/test/random_decimal32_comp.cpp index 335e65b96..6a19aab03 100644 --- a/test/random_decimal32_comp.cpp +++ b/test/random_decimal32_comp.cpp @@ -19,9 +19,9 @@ import boost.decimal; using namespace boost::decimal; #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) -static constexpr auto N = static_cast(1024U); // Number of trials +static constexpr auto N = static_cast(1024); // Number of trials #else -static constexpr auto N = static_cast(1024U >> 4U); // Number of trials +static constexpr auto N = static_cast(1024 >> 4U); // Number of trials #endif // NOLINTNEXTLINE : Seed with a constant for repeatability diff --git a/test/random_decimal32_fast_comp.cpp b/test/random_decimal32_fast_comp.cpp index d0cba04ed..879f9dafb 100644 --- a/test/random_decimal32_fast_comp.cpp +++ b/test/random_decimal32_fast_comp.cpp @@ -19,9 +19,9 @@ import boost.decimal; using namespace boost::decimal; #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) -static constexpr auto N = static_cast(1024U); // Number of trials +static constexpr auto N = static_cast(1024); // Number of trials #else -static constexpr auto N = static_cast(1024U >> 4U); // Number of trials +static constexpr auto N = static_cast(1024 >> 4U); // Number of trials #endif // NOLINTNEXTLINE : Seed with a constant for repeatability diff --git a/test/random_decimal32_fast_math.cpp b/test/random_decimal32_fast_math.cpp index 4714c9bf7..522111e63 100644 --- a/test/random_decimal32_fast_math.cpp +++ b/test/random_decimal32_fast_math.cpp @@ -28,9 +28,9 @@ import boost.decimal; using namespace boost::decimal; #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) -static constexpr auto N = static_cast(1024U); // Number of trials +static constexpr auto N = static_cast(1024); // Number of trials #else -static constexpr auto N = static_cast(1024U >> 4U); // Number of trials +static constexpr auto N = static_cast(1024 >> 4U); // Number of trials #endif // NOLINTNEXTLINE : Seed with a constant for repeatability diff --git a/test/random_decimal32_math.cpp b/test/random_decimal32_math.cpp index 15e58f67c..96efa9172 100644 --- a/test/random_decimal32_math.cpp +++ b/test/random_decimal32_math.cpp @@ -21,9 +21,9 @@ using namespace boost::decimal; #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) -static constexpr auto N = static_cast(1024U); // Number of trials +static constexpr auto N = static_cast(1024); // Number of trials #else -static constexpr auto N = static_cast(1024U >> 4U); // Number of trials +static constexpr auto N = static_cast(1024 >> 4U); // Number of trials #endif // NOLINTNEXTLINE : Seed with a constant for repeatability diff --git a/test/random_decimal64_comp.cpp b/test/random_decimal64_comp.cpp index cc1c9a871..47773edb4 100644 --- a/test/random_decimal64_comp.cpp +++ b/test/random_decimal64_comp.cpp @@ -12,9 +12,9 @@ using namespace boost::decimal; #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) -static constexpr auto N = static_cast(1024U); // Number of trials +static constexpr auto N = static_cast(1024); // Number of trials #else -static constexpr auto N = static_cast(1024U >> 4U); // Number of trials +static constexpr auto N = static_cast(1024 >> 4U); // Number of trials #endif // NOLINTNEXTLINE : Seed with a constant for repeatability diff --git a/test/random_decimal64_fast_comp.cpp b/test/random_decimal64_fast_comp.cpp index dc201aaa1..cf4b02c98 100644 --- a/test/random_decimal64_fast_comp.cpp +++ b/test/random_decimal64_fast_comp.cpp @@ -13,9 +13,9 @@ using namespace boost::decimal; #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) -static constexpr auto N = static_cast(1024U); // Number of trials +static constexpr auto N = static_cast(1024); // Number of trials #else -static constexpr auto N = static_cast(1024U >> 4U); // Number of trials +static constexpr auto N = static_cast(1024 >> 4U); // Number of trials #endif // NOLINTNEXTLINE : Seed with a constant for repeatability diff --git a/test/random_decimal64_fast_math.cpp b/test/random_decimal64_fast_math.cpp index add73e5e1..7f5299dbc 100644 --- a/test/random_decimal64_fast_math.cpp +++ b/test/random_decimal64_fast_math.cpp @@ -21,9 +21,9 @@ using namespace boost::decimal; #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) -static constexpr auto N = static_cast(1024U); // Number of trials +static constexpr auto N = static_cast(1024); // Number of trials #else -static constexpr auto N = static_cast(1024U >> 4U); // Number of trials +static constexpr auto N = static_cast(1024 >> 4U); // Number of trials #endif static std::mt19937_64 rng(42); diff --git a/test/random_decimal64_math.cpp b/test/random_decimal64_math.cpp index f877626cd..517b8dba6 100644 --- a/test/random_decimal64_math.cpp +++ b/test/random_decimal64_math.cpp @@ -21,9 +21,9 @@ using namespace boost::decimal; #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) -static constexpr auto N = static_cast(1024U); // Number of trials +static constexpr auto N = static_cast(1024); // Number of trials #else -static constexpr auto N = static_cast(1024U >> 4U); // Number of trials +static constexpr auto N = static_cast(1024 >> 4U); // Number of trials #endif static std::mt19937_64 rng(42); diff --git a/test/random_mixed_decimal_comp.cpp b/test/random_mixed_decimal_comp.cpp index 357d46b12..07b1933fd 100644 --- a/test/random_mixed_decimal_comp.cpp +++ b/test/random_mixed_decimal_comp.cpp @@ -11,9 +11,9 @@ using namespace boost::decimal; #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) -static constexpr auto N = static_cast(1024U); // Number of trials +static constexpr auto N = static_cast(1024); // Number of trials #else -static constexpr auto N = static_cast(1024U >> 4U); // Number of trials +static constexpr auto N = static_cast(1024 >> 4U); // Number of trials #endif // NOLINTNEXTLINE : Seed with a constant for repeatability diff --git a/test/random_mixed_decimal_math.cpp b/test/random_mixed_decimal_math.cpp index 2ac13bf40..04842730b 100644 --- a/test/random_mixed_decimal_math.cpp +++ b/test/random_mixed_decimal_math.cpp @@ -20,9 +20,9 @@ using namespace boost::decimal; #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) -static constexpr auto N = static_cast(1024U); // Number of trials +static constexpr auto N = static_cast(1024); // Number of trials #else -static constexpr auto N = static_cast(1024U >> 4U); // Number of trials +static constexpr auto N = static_cast(1024 >> 4U); // Number of trials #endif // NOLINTNEXTLINE : Seed with a constant for repeatability diff --git a/test/roundtrip_decimal128.cpp b/test/roundtrip_decimal128.cpp index 4ca58b48f..cb20e5fdb 100644 --- a/test/roundtrip_decimal128.cpp +++ b/test/roundtrip_decimal128.cpp @@ -23,6 +23,7 @@ # pragma GCC diagnostic ignored "-Wconversion" # pragma GCC diagnostic ignored "-Wsign-conversion" # pragma GCC diagnostic ignored "-Wfloat-equal" +# pragma GCC diagnostic ignored "-Wuseless-cast" #endif #include @@ -37,9 +38,9 @@ using namespace boost::decimal; #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) -static constexpr auto N = static_cast(1024U); // Number of trials +static constexpr auto N = static_cast(1024); // Number of trials #else -static constexpr auto N = static_cast(1024U >> 4U); // Number of trials +static constexpr auto N = static_cast(1024 >> 4U); // Number of trials #endif #ifdef _MSC_VER diff --git a/test/roundtrip_decimal128_fast.cpp b/test/roundtrip_decimal128_fast.cpp index a21f3791a..1239502dd 100644 --- a/test/roundtrip_decimal128_fast.cpp +++ b/test/roundtrip_decimal128_fast.cpp @@ -23,6 +23,7 @@ # pragma GCC diagnostic ignored "-Wconversion" # pragma GCC diagnostic ignored "-Wsign-conversion" # pragma GCC diagnostic ignored "-Wfloat-equal" +# pragma GCC diagnostic ignored "-Wuseless-cast" #endif #include @@ -37,9 +38,9 @@ using namespace boost::decimal; #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) -static constexpr auto N = static_cast(1024U); // Number of trials +static constexpr auto N = static_cast(1024); // Number of trials #else -static constexpr auto N = static_cast(1024U >> 4U); // Number of trials +static constexpr auto N = static_cast(1024 >> 4U); // Number of trials #endif #ifdef _MSC_VER diff --git a/test/roundtrip_decimal32.cpp b/test/roundtrip_decimal32.cpp index da3764804..dec87985d 100644 --- a/test/roundtrip_decimal32.cpp +++ b/test/roundtrip_decimal32.cpp @@ -26,9 +26,9 @@ using namespace boost::decimal; #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) -static constexpr auto N = static_cast(1024U); // Number of trials +static constexpr auto N = static_cast(1024); // Number of trials #else -static constexpr auto N = static_cast(1024U >> 4U); // Number of trials +static constexpr auto N = static_cast(1024 >> 4U); // Number of trials #endif #ifdef _MSC_VER diff --git a/test/roundtrip_decimal32_fast.cpp b/test/roundtrip_decimal32_fast.cpp index 5878a0cd7..cfe044510 100644 --- a/test/roundtrip_decimal32_fast.cpp +++ b/test/roundtrip_decimal32_fast.cpp @@ -24,9 +24,9 @@ using namespace boost::decimal; #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) -static constexpr auto N = static_cast(1024U); // Number of trials +static constexpr auto N = static_cast(1024); // Number of trials #else -static constexpr auto N = static_cast(1024U >> 4U); // Number of trials +static constexpr auto N = static_cast(1024 >> 4U); // Number of trials #endif #ifdef _MSC_VER diff --git a/test/roundtrip_decimal64.cpp b/test/roundtrip_decimal64.cpp index f332c28b5..7ffc3972c 100644 --- a/test/roundtrip_decimal64.cpp +++ b/test/roundtrip_decimal64.cpp @@ -24,9 +24,9 @@ using namespace boost::decimal; #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) -static constexpr auto N = static_cast(1024U); // Number of trials +static constexpr auto N = static_cast(1024); // Number of trials #else -static constexpr auto N = static_cast(1024U >> 4U); // Number of trials +static constexpr auto N = static_cast(1024 >> 4U); // Number of trials #endif #ifdef _MSC_VER diff --git a/test/test_acos.cpp b/test/test_acos.cpp index eb30e7840..fcb64aa10 100644 --- a/test/test_acos.cpp +++ b/test/test_acos.cpp @@ -25,6 +25,7 @@ # pragma GCC diagnostic ignored "-Wconversion" # pragma GCC diagnostic ignored "-Wsign-conversion" # pragma GCC diagnostic ignored "-Wfloat-equal" +# pragma GCC diagnostic ignored "-Wuseless-cast" #endif #include @@ -36,9 +37,9 @@ #include #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) -static constexpr auto N = static_cast(128U); // Number of trials +static constexpr auto N = static_cast(128); // Number of trials #else -static constexpr auto N = static_cast(128U >> 4U); // Number of trials +static constexpr auto N = static_cast(128 >> 4U); // Number of trials #endif static std::mt19937_64 rng(42); diff --git a/test/test_acosh.cpp b/test/test_acosh.cpp index 8118346b1..9124897af 100644 --- a/test/test_acosh.cpp +++ b/test/test_acosh.cpp @@ -90,9 +90,9 @@ namespace local auto trials = static_cast(UINT8_C(0)); #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) - constexpr auto count = static_cast(UINT32_C(0x400)); + constexpr auto count = UINT32_C(0x400); #else - constexpr auto count = static_cast(UINT32_C(0x40)); + constexpr auto count = UINT32_C(0x40); #endif for( ; trials < count; ++trials) @@ -226,15 +226,15 @@ auto main() -> int const auto result_eps_is_ok = local::test_acosh ( - static_cast(INT32_C(16) * INT32_C(262144)), + INT32_C(16) * INT32_C(262144), 1.0L + static_cast(std::numeric_limits::epsilon()) * 10.0L, 1.0L + static_cast(std::numeric_limits::epsilon()) * 100.0L ); - const auto result_tiny_is_ok = local::test_acosh(static_cast(INT32_C(4096)), 1.001L, 1.1L); - const auto result_small_is_ok = local::test_acosh(static_cast(INT32_C(96)), 1.1L, 1.59L); - const auto result_medium_is_ok = local::test_acosh(static_cast(INT32_C(48)), 1.59L, 10.1L); - const auto result_large_is_ok = local::test_acosh(static_cast(INT32_C(48)), 1.0E+01L, 1.0E+26L); + const auto result_tiny_is_ok = local::test_acosh(INT32_C(4096), 1.001L, 1.1L); + const auto result_small_is_ok = local::test_acosh(INT32_C(96), 1.1L, 1.59L); + const auto result_medium_is_ok = local::test_acosh(INT32_C(48), 1.59L, 10.1L); + const auto result_large_is_ok = local::test_acosh(INT32_C(48), 1.0E+01L, 1.0E+26L); BOOST_TEST(result_eps_is_ok); BOOST_TEST(result_tiny_is_ok); diff --git a/test/test_asin.cpp b/test/test_asin.cpp index 38eb93227..68e750eb9 100644 --- a/test/test_asin.cpp +++ b/test/test_asin.cpp @@ -26,6 +26,7 @@ # pragma GCC diagnostic ignored "-Wconversion" # pragma GCC diagnostic ignored "-Wsign-conversion" # pragma GCC diagnostic ignored "-Wfloat-equal" +# pragma GCC diagnostic ignored "-Wuseless-cast" #endif #include @@ -35,9 +36,9 @@ #include #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) -static constexpr auto N = static_cast(128U); // Number of trials +static constexpr auto N = static_cast(128); // Number of trials #else -static constexpr auto N = static_cast(128U >> 4U); // Number of trials +static constexpr auto N = static_cast(128 >> 4U); // Number of trials #endif static std::mt19937_64 rng(42); diff --git a/test/test_asinh.cpp b/test/test_asinh.cpp index f4136c3c5..17e58cadf 100644 --- a/test/test_asinh.cpp +++ b/test/test_asinh.cpp @@ -89,9 +89,9 @@ namespace local auto trials = static_cast(UINT8_C(0)); #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) - constexpr auto count = static_cast(UINT32_C(0x400)); + constexpr auto count = UINT32_C(0x400); #else - constexpr auto count = static_cast(UINT32_C(0x40)); + constexpr auto count = UINT32_C(0x40); #endif for( ; trials < count; ++trials) @@ -229,17 +229,17 @@ auto main() -> int const auto result_eps_is_ok = local::test_asinh ( - static_cast(INT32_C(16) * INT32_C(262144)), + INT32_C(16) * INT32_C(262144), false, static_cast(static_cast(fourth_root_epsilon) / 40.0), static_cast(static_cast(fourth_root_epsilon) * 40.0) ); - const auto result_tiny_is_ok = local::test_asinh(static_cast(INT32_C(4096)), false, 1.001, 1.1); - const auto result_small_is_ok = local::test_asinh(static_cast(INT32_C(96)), false, 0.1, 1.59); - const auto result_medium_is_ok = local::test_asinh(static_cast(INT32_C(48)), false, 1.59, 10.1); - const auto result_medium_neg_is_ok = local::test_asinh(static_cast(INT32_C(48)), true, 1.59, 10.1); - const auto result_large_is_ok = local::test_asinh(static_cast(INT32_C(48)), false, 1.0E+01, 1.0E+19); + const auto result_tiny_is_ok = local::test_asinh(INT32_C(4096), false, 1.001, 1.1); + const auto result_small_is_ok = local::test_asinh(INT32_C(96), false, 0.1, 1.59); + const auto result_medium_is_ok = local::test_asinh(INT32_C(48), false, 1.59, 10.1); + const auto result_medium_neg_is_ok = local::test_asinh(INT32_C(48), true, 1.59, 10.1); + const auto result_large_is_ok = local::test_asinh(INT32_C(48), false, 1.0E+01, 1.0E+19); BOOST_TEST(result_eps_is_ok); BOOST_TEST(result_tiny_is_ok); diff --git a/test/test_assoc_laguerre.cpp b/test/test_assoc_laguerre.cpp index 5b56a8eee..f48e0877b 100644 --- a/test/test_assoc_laguerre.cpp +++ b/test/test_assoc_laguerre.cpp @@ -25,6 +25,7 @@ # pragma GCC diagnostic ignored "-Wconversion" # pragma GCC diagnostic ignored "-Wsign-conversion" # pragma GCC diagnostic ignored "-Wfloat-equal" +# pragma GCC diagnostic ignored "-Wuseless-cast" #endif #include @@ -35,9 +36,9 @@ #include #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) -static constexpr auto N = static_cast(128U); // Number of trials +static constexpr auto N = static_cast(128); // Number of trials #else -static constexpr auto N = static_cast(128U >> 4U); // Number of trials +static constexpr auto N = static_cast(128 >> 4U); // Number of trials #endif static std::mt19937_64 rng(42); diff --git a/test/test_assoc_legendre.cpp b/test/test_assoc_legendre.cpp index 92e8bd5ad..8ea3a82ba 100644 --- a/test/test_assoc_legendre.cpp +++ b/test/test_assoc_legendre.cpp @@ -25,6 +25,7 @@ # pragma GCC diagnostic ignored "-Wconversion" # pragma GCC diagnostic ignored "-Wsign-conversion" # pragma GCC diagnostic ignored "-Wfloat-equal" +# pragma GCC diagnostic ignored "-Wuseless-cast" #endif // Windows in Github actions has a broken chrono header diff --git a/test/test_atan.cpp b/test/test_atan.cpp index 7a3739cd5..3193540e1 100644 --- a/test/test_atan.cpp +++ b/test/test_atan.cpp @@ -26,6 +26,7 @@ # pragma GCC diagnostic ignored "-Wconversion" # pragma GCC diagnostic ignored "-Wsign-conversion" # pragma GCC diagnostic ignored "-Wfloat-equal" +# pragma GCC diagnostic ignored "-Wuseless-cast" #endif #include @@ -35,9 +36,9 @@ #include #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) -static constexpr auto N = static_cast(128U); // Number of trials +static constexpr auto N = static_cast(128); // Number of trials #else -static constexpr auto N = static_cast(128U >> 4U); // Number of trials +static constexpr auto N = static_cast(128 >> 4U); // Number of trials #endif namespace local { diff --git a/test/test_atan2.cpp b/test/test_atan2.cpp index 3749edc90..2bc8fa3d8 100644 --- a/test/test_atan2.cpp +++ b/test/test_atan2.cpp @@ -25,6 +25,7 @@ # pragma GCC diagnostic ignored "-Wconversion" # pragma GCC diagnostic ignored "-Wsign-conversion" # pragma GCC diagnostic ignored "-Wfloat-equal" +# pragma GCC diagnostic ignored "-Wuseless-cast" #endif #include @@ -35,9 +36,9 @@ #include #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) -static constexpr auto N = static_cast(128U); // Number of trials +static constexpr auto N = static_cast(128); // Number of trials #else -static constexpr auto N = static_cast(128U >> 4U); // Number of trials +static constexpr auto N = static_cast(128 >> 4U); // Number of trials #endif static std::mt19937_64 rng(42); diff --git a/test/test_atanh.cpp b/test/test_atanh.cpp index 567412a58..cd6b656dc 100644 --- a/test/test_atanh.cpp +++ b/test/test_atanh.cpp @@ -90,9 +90,9 @@ namespace local auto trials = static_cast(UINT8_C(0)); #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) - constexpr auto count = static_cast(UINT32_C(0x400)); + constexpr auto count = UINT32_C(0x400); #else - constexpr auto count = static_cast(UINT32_C(0x40)); + constexpr auto count = UINT32_C(0x40); #endif for( ; trials < count; ++trials) @@ -230,7 +230,7 @@ auto main() -> int const auto result_eps_is_ok = local::test_atanh ( - static_cast(INT32_C(128)), + INT32_C(128), false, static_cast(static_cast(fourth_root_epsilon) / 32.0), static_cast(static_cast(fourth_root_epsilon) * 32.0) @@ -239,15 +239,15 @@ auto main() -> int const auto result_eps_near_one_is_ok = local::test_atanh ( - static_cast(INT32_C(256)), + INT32_C(256), false, static_cast(static_cast( static_cast(1.0L) - static_cast(static_cast(fourth_root_epsilon) * 32.0L))), static_cast(static_cast( static_cast(1.0L) - static_cast(static_cast(fourth_root_epsilon) / 32.0L))) ); - const auto result_tiny_is_ok = local::test_atanh(static_cast(INT32_C(96)), false, 0.001, 0.1); - const auto result_medium_is_ok = local::test_atanh(static_cast(INT32_C(96)), true, 0.1, 0.9); - const auto result_medium_neg_is_ok = local::test_atanh(static_cast(INT32_C(96)), false, 0.1, 0.9); + const auto result_tiny_is_ok = local::test_atanh(INT32_C(96), false, 0.001, 0.1); + const auto result_medium_is_ok = local::test_atanh(INT32_C(96), true, 0.1, 0.9); + const auto result_medium_neg_is_ok = local::test_atanh(INT32_C(96), false, 0.1, 0.9); BOOST_TEST(result_eps_is_ok); BOOST_TEST(result_eps_near_one_is_ok); diff --git a/test/test_beta.cpp b/test/test_beta.cpp index be33dc2c8..dd70a0ff9 100644 --- a/test/test_beta.cpp +++ b/test/test_beta.cpp @@ -26,6 +26,7 @@ # pragma GCC diagnostic ignored "-Wsign-conversion" # pragma GCC diagnostic ignored "-Wfloat-equal" # pragma GCC diagnostic ignored "-Wfloat-conversion" +# pragma GCC diagnostic ignored "-Wuseless-cast" #endif #include @@ -37,9 +38,9 @@ #include #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) -static constexpr auto N = static_cast(128U); // Number of trials +static constexpr auto N = static_cast(128); // Number of trials #else -static constexpr auto N = static_cast(128U >> 4U); // Number of trials +static constexpr auto N = static_cast(128 >> 4U); // Number of trials #endif static std::mt19937_64 rng(42); diff --git a/test/test_big_uints.cpp b/test/test_big_uints.cpp index 7adac665f..487f9f9a7 100644 --- a/test/test_big_uints.cpp +++ b/test/test_big_uints.cpp @@ -46,6 +46,7 @@ int main() # pragma GCC diagnostic ignored "-Wsign-conversion" # pragma GCC diagnostic ignored "-Wfloat-equal" # pragma GCC diagnostic ignored "-Wdeprecated-declarations" +# pragma GCC diagnostic ignored "-Wuseless-cast" #endif #if defined(__GNUC__) && !defined(__clang__) diff --git a/test/test_boost_math_univariate_stats.cpp b/test/test_boost_math_univariate_stats.cpp index 4c7309338..00f2c29b9 100644 --- a/test/test_boost_math_univariate_stats.cpp +++ b/test/test_boost_math_univariate_stats.cpp @@ -35,6 +35,7 @@ # pragma GCC diagnostic ignored "-Wconversion" # pragma GCC diagnostic ignored "-Wsign-conversion" # pragma GCC diagnostic ignored "-Wfloat-equal" +# pragma GCC diagnostic ignored "-Wuseless-cast" #endif #include diff --git a/test/test_cbrt.cpp b/test/test_cbrt.cpp index 59fe01605..7c8713cd9 100644 --- a/test/test_cbrt.cpp +++ b/test/test_cbrt.cpp @@ -101,8 +101,8 @@ namespace local auto dis_sign = std::uniform_int_distribution { - static_cast(INT8_C(0)), - static_cast(INT8_C(1)) + 0, + 1 }; auto result_is_ok = true; @@ -110,9 +110,9 @@ namespace local auto trials = static_cast(UINT8_C(0)); #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) - constexpr auto count = (sizeof(decimal_type) == static_cast(UINT8_C(4))) ? static_cast(UINT32_C(0x400)) : static_cast(UINT32_C(0x40)); + constexpr auto count = (sizeof(decimal_type) == static_cast(UINT8_C(4))) ? UINT32_C(0x400) : UINT32_C(0x40); #else - constexpr auto count = (sizeof(decimal_type) == static_cast(UINT8_C(4))) ? static_cast(UINT32_C(0x40)) : static_cast(UINT32_C(0x4)); + constexpr auto count = (sizeof(decimal_type) == static_cast(UINT8_C(4))) ? UINT32_C(0x40) : UINT32_C(0x4); #endif for( ; trials < count; ++trials) @@ -341,9 +341,9 @@ int main() using decimal_type = boost::decimal::decimal32_t; using float_type = float; - const auto result_small_is_ok = local::test_cbrt(static_cast(INT32_C(16)), 1.0E-26L, 1.0E-01L); - const auto result_medium_is_ok = local::test_cbrt(static_cast(INT32_C(16)), 0.9E-01L, 1.1E+01L); - const auto result_large_is_ok = local::test_cbrt(static_cast(INT32_C(16)), 1.0E+01L, 1.0E+26L); + const auto result_small_is_ok = local::test_cbrt(INT32_C(16), 1.0E-26L, 1.0E-01L); + const auto result_medium_is_ok = local::test_cbrt(INT32_C(16), 0.9E-01L, 1.1E+01L); + const auto result_large_is_ok = local::test_cbrt(INT32_C(16), 1.0E+01L, 1.0E+26L); BOOST_TEST(result_small_is_ok); BOOST_TEST(result_medium_is_ok); @@ -364,9 +364,9 @@ int main() using decimal_type = boost::decimal::decimal_fast32_t; using float_type = float; - const auto result_small_is_ok = local::test_cbrt(static_cast(INT32_C(16)), 1.0E-26L, 1.0E-01L); - const auto result_medium_is_ok = local::test_cbrt(static_cast(INT32_C(16)), 0.9E-01L, 1.1E+01L); - const auto result_large_is_ok = local::test_cbrt(static_cast(INT32_C(16)), 1.0E+01L, 1.0E+26L); + const auto result_small_is_ok = local::test_cbrt(INT32_C(16), 1.0E-26L, 1.0E-01L); + const auto result_medium_is_ok = local::test_cbrt(INT32_C(16), 0.9E-01L, 1.1E+01L); + const auto result_large_is_ok = local::test_cbrt(INT32_C(16), 1.0E+01L, 1.0E+26L); BOOST_TEST(result_small_is_ok); BOOST_TEST(result_medium_is_ok); @@ -387,9 +387,9 @@ int main() using decimal_type = boost::decimal::decimal64_t; using float_type = double; - const auto result_small_is_ok = local::test_cbrt(static_cast(INT32_C(16)), 1.0E-76L, 1.0E-01L); - const auto result_medium_is_ok = local::test_cbrt(static_cast(INT32_C(16)), 0.9E-01L, 1.1E+01L); - const auto result_large_is_ok = local::test_cbrt(static_cast(INT32_C(16)), 1.0E+01L, 1.0E+76L); + const auto result_small_is_ok = local::test_cbrt(INT32_C(16), 1.0E-76L, 1.0E-01L); + const auto result_medium_is_ok = local::test_cbrt(INT32_C(16), 0.9E-01L, 1.1E+01L); + const auto result_large_is_ok = local::test_cbrt(INT32_C(16), 1.0E+01L, 1.0E+76L); BOOST_TEST(result_small_is_ok); BOOST_TEST(result_medium_is_ok); diff --git a/test/test_cmath.cpp b/test/test_cmath.cpp index 4bc22ebc1..b092d4b8e 100644 --- a/test/test_cmath.cpp +++ b/test/test_cmath.cpp @@ -32,6 +32,7 @@ # pragma GCC diagnostic ignored "-Wconversion" # pragma GCC diagnostic ignored "-Wsign-conversion" # pragma GCC diagnostic ignored "-Wfloat-equal" +# pragma GCC diagnostic ignored "-Wuseless-cast" #endif #include @@ -43,9 +44,9 @@ #include #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) && !defined(_WIN32) -static constexpr auto N = static_cast(128U); // Number of trials +static constexpr auto N = static_cast(128); // Number of trials #else -static constexpr auto N = static_cast(128U >> 4U); // Number of trials +static constexpr auto N = static_cast(128 >> 4U); // Number of trials #endif static std::mt19937_64 rng(42); diff --git a/test/test_cosh.cpp b/test/test_cosh.cpp index f0118767e..4cc0719da 100644 --- a/test/test_cosh.cpp +++ b/test/test_cosh.cpp @@ -104,9 +104,9 @@ namespace local auto trials = static_cast(UINT8_C(0)); #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) - constexpr auto count = static_cast(UINT32_C(0x400)); + constexpr auto count = UINT32_C(0x400); #else - constexpr auto count = static_cast(UINT32_C(0x40)); + constexpr auto count = UINT32_C(0x40); #endif for( ; trials < count; ++trials) diff --git a/test/test_decimal_quantum.cpp b/test/test_decimal_quantum.cpp index 4126a4f22..3672419a9 100644 --- a/test/test_decimal_quantum.cpp +++ b/test/test_decimal_quantum.cpp @@ -18,9 +18,9 @@ using namespace boost::decimal; #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) -static constexpr auto N = static_cast(1024U); // Number of trials +static constexpr auto N = static_cast(1024); // Number of trials #else -static constexpr auto N = static_cast(1024U >> 4U); // Number of trials +static constexpr auto N = static_cast(1024 >> 4U); // Number of trials #endif // NOLINTNEXTLINE : Seed with a constant for repeatability diff --git a/test/test_edges_and_behave.cpp b/test/test_edges_and_behave.cpp index 0d90fb4fe..a8f931a92 100644 --- a/test/test_edges_and_behave.cpp +++ b/test/test_edges_and_behave.cpp @@ -85,7 +85,7 @@ namespace local { static_cast(i); - const auto local_nan_to_construct_f = decimal_type { std::numeric_limits::quiet_NaN() * static_cast(dist(gen)) }; + const auto local_nan_to_construct_f = decimal_type { std::numeric_limits::quiet_NaN() * dist(gen) }; const auto local_nan_to_construct_d = decimal_type { std::numeric_limits::quiet_NaN() * static_cast(dist(gen)) }; #ifndef BOOST_DECIMAL_UNSUPPORTED_LONG_DOUBLE diff --git a/test/test_edit_members.cpp b/test/test_edit_members.cpp index 8f325c9cc..0fa887c72 100644 --- a/test/test_edit_members.cpp +++ b/test/test_edit_members.cpp @@ -13,9 +13,9 @@ using namespace boost::decimal; #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) -static constexpr auto N = static_cast(1024U); // Number of trials +static constexpr auto N = static_cast(1024); // Number of trials #else -static constexpr auto N = static_cast(1024U >> 4U); // Number of trials +static constexpr auto N = static_cast(1024 >> 4U); // Number of trials #endif // NOLINTNEXTLINE : Seed with a constant for repeatability diff --git a/test/test_ellint_1.cpp b/test/test_ellint_1.cpp index c293dc7e0..b0fd39d2d 100644 --- a/test/test_ellint_1.cpp +++ b/test/test_ellint_1.cpp @@ -30,6 +30,7 @@ # if __GNUC__ == 10 # pragma GCC diagnostic ignored "-Wmisleading-indentation" # endif +# pragma GCC diagnostic ignored "-Wuseless-cast" #endif #include @@ -64,7 +65,7 @@ namespace local #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) static constexpr auto N = static_cast(64U); #else -static constexpr auto N = static_cast(8U); +static constexpr auto N = static_cast(8); #endif static std::mt19937_64 rng(42); diff --git a/test/test_ellint_2.cpp b/test/test_ellint_2.cpp index d310141f9..bd9fde8f7 100644 --- a/test/test_ellint_2.cpp +++ b/test/test_ellint_2.cpp @@ -30,6 +30,7 @@ # if __GNUC__ == 10 # pragma GCC diagnostic ignored "-Wmisleading-indentation" # endif +# pragma GCC diagnostic ignored "-Wuseless-cast" #endif #include @@ -64,7 +65,7 @@ namespace local #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) static constexpr auto N = static_cast(64U); #else -static constexpr auto N = static_cast(8U); +static constexpr auto N = static_cast(8); #endif static std::mt19937_64 rng(42); diff --git a/test/test_erf.cpp b/test/test_erf.cpp index 5d395cab4..e5d52097a 100644 --- a/test/test_erf.cpp +++ b/test/test_erf.cpp @@ -25,6 +25,7 @@ # pragma GCC diagnostic ignored "-Wconversion" # pragma GCC diagnostic ignored "-Wsign-conversion" # pragma GCC diagnostic ignored "-Wfloat-equal" +# pragma GCC diagnostic ignored "-Wuseless-cast" #endif #include #include diff --git a/test/test_exp.cpp b/test/test_exp.cpp index 3b8e02594..ecf164cf3 100644 --- a/test/test_exp.cpp +++ b/test/test_exp.cpp @@ -106,9 +106,9 @@ namespace local auto trials = static_cast(UINT8_C(0)); #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) - constexpr auto count = (sizeof(decimal_type) == static_cast(UINT8_C(4))) ? static_cast(UINT32_C(0x400)) : static_cast(UINT32_C(0x40)); + constexpr auto count = (sizeof(decimal_type) == static_cast(UINT8_C(4))) ? UINT32_C(0x400) : UINT32_C(0x40); #else - constexpr auto count = (sizeof(decimal_type) == static_cast(UINT8_C(4))) ? static_cast(UINT32_C(0x40)) : static_cast(UINT32_C(0x4)); + constexpr auto count = (sizeof(decimal_type) == static_cast(UINT8_C(4))) ? UINT32_C(0x40) : UINT32_C(0x4); #endif for( ; trials < count; ++trials) diff --git a/test/test_expm1.cpp b/test/test_expm1.cpp index 3642eb45b..c2660ec6a 100644 --- a/test/test_expm1.cpp +++ b/test/test_expm1.cpp @@ -103,9 +103,9 @@ namespace local auto trials = static_cast(UINT8_C(0)); #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) - constexpr auto count = static_cast(UINT32_C(0x400)); + constexpr auto count = UINT32_C(0x400); #else - constexpr auto count = static_cast(UINT32_C(0x40)); + constexpr auto count = UINT32_C(0x40); #endif for( ; trials < count; ++trials) diff --git a/test/test_fast_math.cpp b/test/test_fast_math.cpp index 468f1bac6..9d1d28917 100644 --- a/test/test_fast_math.cpp +++ b/test/test_fast_math.cpp @@ -13,9 +13,9 @@ using namespace boost::decimal; #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) -static constexpr auto N = static_cast(1024U); // Number of trials +static constexpr auto N = static_cast(1024); // Number of trials #else -static constexpr auto N = static_cast(1024U >> 4U); // Number of trials +static constexpr auto N = static_cast(1024 >> 4U); // Number of trials #endif // NOLINTNEXTLINE : Seed with a constant for repeatability diff --git a/test/test_frexp_ldexp.cpp b/test/test_frexp_ldexp.cpp index 201558489..3144415d7 100644 --- a/test/test_frexp_ldexp.cpp +++ b/test/test_frexp_ldexp.cpp @@ -145,9 +145,9 @@ namespace local auto test_frexp_ldexp() -> bool { #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) - constexpr auto test_frexp_ldexp_depth = static_cast(UINT32_C(0x800)); + constexpr auto test_frexp_ldexp_depth = UINT32_C(0x800); #else - constexpr auto test_frexp_ldexp_depth = static_cast(UINT32_C(0x80)); + constexpr auto test_frexp_ldexp_depth = UINT32_C(0x80); #endif const local::test_frexp_ldexp_ctrl flt_ctrl[static_cast(UINT8_C(7))] = diff --git a/test/test_from_chars.cpp b/test/test_from_chars.cpp index baabb199b..48e8b75f3 100644 --- a/test/test_from_chars.cpp +++ b/test/test_from_chars.cpp @@ -7,7 +7,6 @@ #include "mini_to_chars.hpp" #include -#include #if defined(__clang__) # pragma clang diagnostic push @@ -26,8 +25,10 @@ # pragma GCC diagnostic ignored "-Wconversion" # pragma GCC diagnostic ignored "-Wsign-conversion" # pragma GCC diagnostic ignored "-Wfloat-equal" +# pragma GCC diagnostic ignored "-Wuseless-cast" #endif +#include #include #include #include @@ -41,9 +42,9 @@ using namespace boost::decimal; static std::mt19937_64 rng(42); #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) -static constexpr auto N = static_cast(1024U); // Number of trials +static constexpr auto N = static_cast(1024); // Number of trials #else -static constexpr auto N = static_cast(1024U >> 4U); // Number of trials +static constexpr auto N = static_cast(1024 >> 4U); // Number of trials #endif #if !defined(BOOST_DECIMAL_DISABLE_CLIB) diff --git a/test/test_hermite.cpp b/test/test_hermite.cpp index 63ef25f7e..eac92a027 100644 --- a/test/test_hermite.cpp +++ b/test/test_hermite.cpp @@ -25,6 +25,7 @@ # pragma GCC diagnostic ignored "-Wconversion" # pragma GCC diagnostic ignored "-Wsign-conversion" # pragma GCC diagnostic ignored "-Wfloat-equal" +# pragma GCC diagnostic ignored "-Wuseless-cast" #endif #include @@ -35,9 +36,9 @@ #include #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) -static constexpr auto N = static_cast(128U); // Number of trials +static constexpr auto N = static_cast(128); // Number of trials #else -static constexpr auto N = static_cast(128U >> 4U); // Number of trials +static constexpr auto N = static_cast(128 >> 4U); // Number of trials #endif static std::mt19937_64 rng(42); diff --git a/test/test_laguerre.cpp b/test/test_laguerre.cpp index 70af27d47..3d70f1143 100644 --- a/test/test_laguerre.cpp +++ b/test/test_laguerre.cpp @@ -25,6 +25,7 @@ # pragma GCC diagnostic ignored "-Wconversion" # pragma GCC diagnostic ignored "-Wsign-conversion" # pragma GCC diagnostic ignored "-Wfloat-equal" +# pragma GCC diagnostic ignored "-Wuseless-cast" #endif #include @@ -35,9 +36,9 @@ #include #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) -static constexpr auto N = static_cast(128U); // Number of trials +static constexpr auto N = static_cast(128); // Number of trials #else -static constexpr auto N = static_cast(128U >> 4U); // Number of trials +static constexpr auto N = static_cast(128 >> 4U); // Number of trials #endif static std::mt19937_64 rng(42); diff --git a/test/test_legendre.cpp b/test/test_legendre.cpp index 71a37f567..b8e3d9279 100644 --- a/test/test_legendre.cpp +++ b/test/test_legendre.cpp @@ -25,6 +25,7 @@ # pragma GCC diagnostic ignored "-Wconversion" # pragma GCC diagnostic ignored "-Wsign-conversion" # pragma GCC diagnostic ignored "-Wfloat-equal" +# pragma GCC diagnostic ignored "-Wuseless-cast" #endif #include @@ -35,9 +36,9 @@ #include #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) -static constexpr auto N = static_cast(128U); // Number of trials +static constexpr auto N = static_cast(128); // Number of trials #else -static constexpr auto N = static_cast(128U >> 4U); // Number of trials +static constexpr auto N = static_cast(128 >> 4U); // Number of trials #endif static std::mt19937_64 rng(42); diff --git a/test/test_lgamma.cpp b/test/test_lgamma.cpp index 97346ef52..a00da2e3b 100644 --- a/test/test_lgamma.cpp +++ b/test/test_lgamma.cpp @@ -139,9 +139,9 @@ namespace local auto trials = static_cast(UINT8_C(0)); #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) - constexpr auto count = (sizeof(decimal_type) == static_cast(UINT8_C(4))) ? static_cast(UINT32_C(0x200)) : static_cast(UINT32_C(0x20)); + constexpr auto count = (sizeof(decimal_type) == static_cast(UINT8_C(4))) ? UINT32_C(0x200) : UINT32_C(0x20); #else - constexpr auto count = (sizeof(decimal_type) == static_cast(UINT8_C(4))) ? static_cast(UINT32_C(0x20)) : static_cast(UINT32_C(0x4)); + constexpr auto count = (sizeof(decimal_type) == static_cast(UINT8_C(4))) ? UINT32_C(0x20) : UINT32_C(0x4); #endif for( ; trials < count; ++trials) @@ -187,18 +187,18 @@ namespace local constexpr auto ctrl_values = ctrl_as_long_double_array_type { - static_cast(+1.4447269693351526224039790879560L), - static_cast(+0.64272538386312523180385678760158L), - static_cast(-0.52975675337143994041872235279067L), - static_cast(-1.9719587464296265419941805870392L), - static_cast(-3.6263700245064580747683408545835L), - static_cast(-5.4557463573058198501555262293278L), - static_cast(-7.4339853934764931689811998755925L), - static_cast(-9.5417714081654716128550899316691L), - static_cast(-11.764230456680232402202048996379L), - static_cast(-14.089555036643767515552419226440L), - static_cast(-16.508143805394119328051805784031L), - static_cast(-19.012035755093200315277355952189L), + +1.4447269693351526224039790879560L, + +0.64272538386312523180385678760158L, + -0.52975675337143994041872235279067L, + -1.9719587464296265419941805870392L, + -3.6263700245064580747683408545835L, + -5.4557463573058198501555262293278L, + -7.4339853934764931689811998755925L, + -9.5417714081654716128550899316691L, + -11.764230456680232402202048996379L, + -14.089555036643767515552419226440L, + -16.508143805394119328051805784031L, + -19.012035755093200315277355952189L, }; auto result_is_ok = true; @@ -210,7 +210,7 @@ namespace local n < std::tuple_size::value; ++n) { - const auto ld_arg = static_cast(-0.23L - static_cast(n + 1U)); + const auto ld_arg = -0.23L - static_cast(n + 1U); const auto x_dec = static_cast(ld_arg); const auto x_flt = static_cast(ld_arg); @@ -325,7 +325,7 @@ namespace local for(auto i = static_cast(UINT8_C(0)); i < static_cast(UINT8_C(6)); ++i) { - const auto n_neg = static_cast(-static_cast(i) - 1); + const auto n_neg = -static_cast(i) - 1; const auto val_neg_int = lgamma( decimal_type { n_neg, 0 } ); diff --git a/test/test_log.cpp b/test/test_log.cpp index 8ce457913..3c523dbb2 100644 --- a/test/test_log.cpp +++ b/test/test_log.cpp @@ -114,9 +114,9 @@ namespace local auto trials = static_cast(UINT8_C(0)); #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) - constexpr auto count = (sizeof(decimal_type) == static_cast(UINT8_C(4))) ? static_cast(UINT32_C(0x200)) : static_cast(UINT32_C(0x40)); + constexpr auto count = (sizeof(decimal_type) == static_cast(UINT8_C(4))) ? UINT32_C(0x200) : UINT32_C(0x40); #else - constexpr auto count = (sizeof(decimal_type) == static_cast(UINT8_C(4))) ? static_cast(UINT32_C(0x40)) : static_cast(UINT32_C(0x4)); + constexpr auto count = (sizeof(decimal_type) == static_cast(UINT8_C(4))) ? UINT32_C(0x40) : UINT32_C(0x4); #endif for( ; trials < count; ++trials) diff --git a/test/test_log10.cpp b/test/test_log10.cpp index 89c02a79c..56cedb21e 100644 --- a/test/test_log10.cpp +++ b/test/test_log10.cpp @@ -108,9 +108,9 @@ namespace local auto trials = static_cast(UINT8_C(0)); #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) - constexpr auto count = (sizeof(decimal_type) == static_cast(UINT8_C(4))) ? static_cast(UINT32_C(0x200)) : static_cast(UINT32_C(0x40)); + constexpr auto count = (sizeof(decimal_type) == static_cast(UINT8_C(4))) ? UINT32_C(0x200) : UINT32_C(0x40); #else - constexpr auto count = (sizeof(decimal_type) == static_cast(UINT8_C(4))) ? static_cast(UINT32_C(0x40)) : static_cast(UINT32_C(0x4)); + constexpr auto count = (sizeof(decimal_type) == static_cast(UINT8_C(4))) ? UINT32_C(0x40) : UINT32_C(0x4); #endif for( ; trials < count; ++trials) @@ -120,8 +120,8 @@ namespace local auto dis_n = std::uniform_int_distribution { - static_cast(INT8_C(-17)), - static_cast(INT8_C(17)) + -17, + 17 }; std::string str_e { "1.0E" + std::to_string(dis_n(gen)) }; @@ -168,7 +168,7 @@ namespace local bool result_is_ok { true }; - for(int i = static_cast(INT8_C(-23)); i <= static_cast(INT8_C(23)); ++i) + for(int i = INT8_C(-23); i <= INT8_C(23); ++i) { const decimal_type x_arg { 1, i }; diff --git a/test/test_log1p.cpp b/test/test_log1p.cpp index 760e6d07a..5fe31d93f 100644 --- a/test/test_log1p.cpp +++ b/test/test_log1p.cpp @@ -106,9 +106,9 @@ namespace local auto trials = static_cast(UINT8_C(0)); #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) - constexpr auto count = static_cast(UINT32_C(0x400)); + constexpr auto count = UINT32_C(0x400); #else - constexpr auto count = static_cast(UINT32_C(0x40)); + constexpr auto count = UINT32_C(0x40); #endif for( ; trials < count; ++trials) diff --git a/test/test_pow.cpp b/test/test_pow.cpp index 81244491c..f5d129f5e 100644 --- a/test/test_pow.cpp +++ b/test/test_pow.cpp @@ -102,9 +102,9 @@ namespace local auto trials = static_cast(UINT8_C(0)); #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) - constexpr auto count = (sizeof(decimal_type) == static_cast(UINT8_C(4))) ? static_cast(UINT32_C(0x400)) : static_cast(UINT32_C(0x40)); + constexpr auto count = (sizeof(decimal_type) == static_cast(UINT8_C(4))) ? UINT32_C(0x400) : UINT32_C(0x40); #else - constexpr auto count = (sizeof(decimal_type) == static_cast(UINT8_C(4))) ? static_cast(UINT32_C(0x40)) : static_cast(UINT32_C(0x4)); + constexpr auto count = (sizeof(decimal_type) == static_cast(UINT8_C(4))) ? UINT32_C(0x40) : UINT32_C(0x4); #endif for( ; trials < count; ++trials) @@ -336,7 +336,7 @@ namespace local decimal_type p10 = pow(pow(::my_ten(), n), n); - const bool result_p10_is_ok = (p10 == ctrl_values[static_cast(i)]); + const bool result_p10_is_ok = (p10 == ctrl_values[i]); result_is_ok = (result_p10_is_ok && result_is_ok); } @@ -358,7 +358,7 @@ namespace local decimal_type p10 = pow(pow(::my_ten(), -n), n); - const bool result_p10_is_ok = (p10 == ctrl_values[static_cast(i)]); + const bool result_p10_is_ok = (p10 == ctrl_values[i]); result_is_ok = (result_p10_is_ok && result_is_ok); } @@ -751,8 +751,8 @@ namespace local std::uniform_int_distribution dist_n ( - static_cast(INT8_C(2)), - static_cast(INT8_C(12)) + 2, + 12 ); using std::fpclassify; @@ -829,7 +829,7 @@ namespace local result_is_ok = (result_val_pow2_zero_is_ok && result_is_ok); } - for(auto index = static_cast(UINT8_C(2)); index <= static_cast(UINT8_C(10)); index += static_cast(UINT8_C(2))) + for(auto index = 2; index <= 10; index += 2) { const auto dec_zero_pos = pow(::my_zero() * static_cast(dist(gen)), decimal_type(index)); const auto flt_zero_pos = pow(static_cast(0.0L), static_cast(index)); @@ -845,7 +845,7 @@ namespace local result_is_ok = (result_val_zero_pos_is_ok && result_is_ok); } - for(auto index = static_cast(UINT8_C(2)); index <= static_cast(UINT8_C(10)); index += static_cast(UINT8_C(2))) + for(auto index = 2; index <= 10; index += 2) { const auto dec_zero_neg = pow(-::my_zero() * static_cast(dist(gen)), decimal_type(index)); const auto flt_zero_neg = pow(static_cast(-0.0L), static_cast(index)); @@ -861,7 +861,7 @@ namespace local result_is_ok = (result_val_zero_neg_is_ok && result_is_ok); } - for(auto index = static_cast(UINT8_C(3)); index <= static_cast(UINT8_C(11)); index += static_cast(UINT8_C(2))) + for(auto index = 3; index <= 11; index += 2) { const auto dec_zero_pos = pow(::my_zero() * static_cast(dist(gen)), decimal_type(index)); const auto flt_zero_pos = pow(static_cast(0.0L), static_cast(index)); @@ -877,7 +877,7 @@ namespace local result_is_ok = (result_val_zero_pos_is_ok && result_is_ok); } - for(auto index = static_cast(UINT8_C(3)); index <= static_cast(UINT8_C(11)); index += static_cast(UINT8_C(2))) + for(auto index = 3; index <= 11; index += 2) { const decimal_type arg_zero_neg = -(::my_zero() * static_cast(dist(gen))); @@ -895,7 +895,7 @@ namespace local result_is_ok = (result_val_zero_neg_is_ok && result_is_ok); } - for(auto index = static_cast(INT8_C(-11)); index <= static_cast(INT8_C(-3)); index += static_cast(INT8_C(2))) + for(auto index = -11; index <= -3; index += 2) { const auto dec_zero_pos = pow(::my_zero() * static_cast(dist(gen)), decimal_type(index)); const auto flt_zero_pos = pow(static_cast(0.0L), static_cast(index)); @@ -911,7 +911,7 @@ namespace local result_is_ok = (result_val_zero_pos_is_ok && result_is_ok); } - for(auto index = static_cast(INT8_C(-11)); index <= static_cast(INT8_C(-3)); index += static_cast(INT8_C(2))) + for(auto index = -11; index <= -3; index += 2) { const auto dec_zero_neg = pow(-::my_zero() * static_cast(dist(gen)), decimal_type(index)); @@ -922,7 +922,7 @@ namespace local result_is_ok = (result_val_zero_neg_is_ok && result_is_ok); } - for(auto index = static_cast(INT8_C(-10)); index <= static_cast(INT8_C(-2)); index += static_cast(INT8_C(2))) + for(auto index = -10; index <= -2; index += 2) { const auto dec_zero_pos = pow(::my_zero() * static_cast(dist(gen)), decimal_type(index)); const auto flt_zero_pos = pow(static_cast(0.0L), static_cast(index)); @@ -938,7 +938,7 @@ namespace local result_is_ok = (result_val_zero_pos_is_ok && result_is_ok); } - for(auto index = static_cast(INT8_C(-10)); index <= static_cast(INT8_C(-2)); index += static_cast(INT8_C(2))) + for(auto index = -10; index <= -2; index += 2) { const auto dec_zero_neg = pow(-::my_zero() * static_cast(dist(gen)), decimal_type(index)); const auto flt_zero_neg = pow(-static_cast(0.0L), static_cast(index)); diff --git a/test/test_remainder_remquo.cpp b/test/test_remainder_remquo.cpp index e36e335c4..cd8714ef4 100644 --- a/test/test_remainder_remquo.cpp +++ b/test/test_remainder_remquo.cpp @@ -25,6 +25,7 @@ # pragma GCC diagnostic ignored "-Wconversion" # pragma GCC diagnostic ignored "-Wsign-conversion" # pragma GCC diagnostic ignored "-Wfloat-equal" +# pragma GCC diagnostic ignored "-Wuseless-cast" #endif #include @@ -35,9 +36,9 @@ #include #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) -static constexpr auto N = static_cast(128U); // Number of trials +static constexpr auto N = static_cast(128); // Number of trials #else -static constexpr auto N = static_cast(128U >> 4U); // Number of trials +static constexpr auto N = static_cast(128 >> 4U); // Number of trials #endif static std::mt19937_64 rng(42); diff --git a/test/test_sin_cos.cpp b/test/test_sin_cos.cpp index f7baa89cd..cfb3a1d74 100644 --- a/test/test_sin_cos.cpp +++ b/test/test_sin_cos.cpp @@ -27,6 +27,7 @@ # pragma GCC diagnostic ignored "-Wconversion" # pragma GCC diagnostic ignored "-Wsign-conversion" # pragma GCC diagnostic ignored "-Wfloat-equal" +# pragma GCC diagnostic ignored "-Wuseless-cast" #endif #include @@ -35,9 +36,9 @@ #include #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) -static constexpr auto N = static_cast(128U); // Number of trials +static constexpr auto N = static_cast(128); // Number of trials #else -static constexpr auto N = static_cast(128U >> 4U); // Number of trials +static constexpr auto N = static_cast(128 >> 4U); // Number of trials #endif static std::mt19937_64 rng(42); diff --git a/test/test_sinh.cpp b/test/test_sinh.cpp index 539b9cc41..74dd83fdd 100644 --- a/test/test_sinh.cpp +++ b/test/test_sinh.cpp @@ -103,9 +103,9 @@ namespace local auto trials = static_cast(UINT8_C(0)); #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) - constexpr auto count = static_cast(UINT32_C(0x400)); + constexpr auto count = UINT32_C(0x400); #else - constexpr auto count = static_cast(UINT32_C(0x40)); + constexpr auto count = UINT32_C(0x40); #endif for( ; trials < count; ++trials) diff --git a/test/test_sqrt.cpp b/test/test_sqrt.cpp index 578cb2db5..2847913bc 100644 --- a/test/test_sqrt.cpp +++ b/test/test_sqrt.cpp @@ -92,9 +92,9 @@ namespace local auto trials = static_cast(UINT8_C(0)); #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) - constexpr auto count = (sizeof(decimal_type) == static_cast(UINT8_C(4))) ? static_cast(UINT32_C(0x400)) : static_cast(UINT32_C(0x40)); + constexpr auto count = (sizeof(decimal_type) == static_cast(UINT8_C(4))) ? UINT32_C(0x400) : UINT32_C(0x40); #else - constexpr auto count = (sizeof(decimal_type) == static_cast(UINT8_C(4))) ? static_cast(UINT32_C(0x40)) : static_cast(UINT32_C(0x4)); + constexpr auto count = (sizeof(decimal_type) == static_cast(UINT8_C(4))) ? UINT32_C(0x40) : UINT32_C(0x4); #endif for( ; trials < count; ++trials) @@ -353,9 +353,9 @@ auto main() -> int using decimal_type = boost::decimal::decimal32_t; using float_type = float; - const auto result_small_is_ok = local::test_sqrt(static_cast(INT32_C(16)), 1.0E-26L, 1.0E-01L); - const auto result_medium_is_ok = local::test_sqrt(static_cast(INT32_C(16)), 0.9E-01L, 1.1E+01L); - const auto result_large_is_ok = local::test_sqrt(static_cast(INT32_C(16)), 1.0E+01L, 1.0E+26L); + const auto result_small_is_ok = local::test_sqrt(16, 1.0E-26L, 1.0E-01L); + const auto result_medium_is_ok = local::test_sqrt(16, 0.9E-01L, 1.1E+01L); + const auto result_large_is_ok = local::test_sqrt(16, 1.0E+01L, 1.0E+26L); BOOST_TEST(result_small_is_ok); BOOST_TEST(result_medium_is_ok); @@ -376,9 +376,9 @@ auto main() -> int using decimal_type = boost::decimal::decimal64_t; using float_type = double; - const auto result_small_is_ok = local::test_sqrt(static_cast(INT32_C(16)), 1.0E-76L, 1.0E-01L); - const auto result_medium_is_ok = local::test_sqrt(static_cast(INT32_C(16)), 0.9E-01L, 1.1E+01L); - const auto result_large_is_ok = local::test_sqrt(static_cast(INT32_C(16)), 1.0E+01L, 1.0E+76L); + const auto result_small_is_ok = local::test_sqrt(16, 1.0E-76L, 1.0E-01L); + const auto result_medium_is_ok = local::test_sqrt(16, 0.9E-01L, 1.1E+01L); + const auto result_large_is_ok = local::test_sqrt(16, 1.0E+01L, 1.0E+76L); BOOST_TEST(result_small_is_ok); BOOST_TEST(result_medium_is_ok); diff --git a/test/test_strtod.cpp b/test/test_strtod.cpp index 453c13bcd..37558bcc4 100644 --- a/test/test_strtod.cpp +++ b/test/test_strtod.cpp @@ -36,9 +36,9 @@ using namespace boost::decimal; #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) -static constexpr auto N = static_cast(1024U); // Number of trials +static constexpr auto N = static_cast(1024); // Number of trials #else -static constexpr auto N = static_cast(1024U >> 4U); // Number of trials +static constexpr auto N = static_cast(1024 >> 4U); // Number of trials #endif template diff --git a/test/test_tan.cpp b/test/test_tan.cpp index f112612e3..48416cf61 100644 --- a/test/test_tan.cpp +++ b/test/test_tan.cpp @@ -89,9 +89,9 @@ namespace local auto trials = static_cast(UINT8_C(0)); #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) - constexpr auto count = static_cast(UINT32_C(0x400)); + constexpr auto count = UINT32_C(0x400); #else - constexpr auto count = static_cast(UINT32_C(0x40)); + constexpr auto count = UINT32_C(0x40); #endif for( ; trials < count; ++trials) diff --git a/test/test_tanh.cpp b/test/test_tanh.cpp index ffe11d8a7..8f3bb9b8d 100644 --- a/test/test_tanh.cpp +++ b/test/test_tanh.cpp @@ -104,9 +104,9 @@ namespace local auto trials = static_cast(UINT8_C(0)); #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) - constexpr auto count = static_cast(UINT32_C(0x800)); + constexpr auto count = UINT32_C(0x800); #else - constexpr auto count = static_cast(UINT32_C(0x80)); + constexpr auto count = UINT32_C(0x80); #endif for( ; trials < count; ++trials) diff --git a/test/test_tgamma.cpp b/test/test_tgamma.cpp index 6d4ca59c0..04dad2006 100644 --- a/test/test_tgamma.cpp +++ b/test/test_tgamma.cpp @@ -107,9 +107,9 @@ namespace local auto trials = static_cast(UINT8_C(0)); #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) - constexpr auto count = (sizeof(decimal_type) == static_cast(UINT8_C(4))) ? static_cast(UINT32_C(0x400)) : static_cast(UINT32_C(0x40)); + constexpr auto count = (sizeof(decimal_type) == static_cast(UINT8_C(4))) ? UINT32_C(0x400) : UINT32_C(0x40); #else - constexpr auto count = (sizeof(decimal_type) == static_cast(UINT8_C(4))) ? static_cast(UINT32_C(0x40)) : static_cast(UINT32_C(0x4)); + constexpr auto count = (sizeof(decimal_type) == static_cast(UINT8_C(4))) ? UINT32_C(0x40) : UINT32_C(0x4); #endif for( ; trials < count; ++trials) @@ -152,13 +152,13 @@ namespace local constexpr auto ctrl_values = ctrl_as_long_double_array_type { - static_cast(+4.2406941452013198921659716327521L), - static_cast(-1.9016565673548519695811531985435L), - static_cast(+0.58874816326775602773410315744382L), - static_cast(-0.13918396294746005383784944620421L), - static_cast(+0.026612612418252400351405247840194L), - static_cast(-0.0042716873865573676326493174703360L), - static_cast(+0.00059082813092079773618939384098700L) + +4.2406941452013198921659716327521L, + -1.9016565673548519695811531985435L, + +0.58874816326775602773410315744382L, + -0.13918396294746005383784944620421L, + +0.026612612418252400351405247840194L, + -0.0042716873865573676326493174703360L, + +0.00059082813092079773618939384098700L }; auto result_is_ok = true; @@ -170,7 +170,7 @@ namespace local n < std::tuple_size::value; ++n) { - const auto ld_arg = static_cast(-0.23L - static_cast(n + 1U)); + const auto ld_arg = -0.23L - static_cast(n + 1U); const auto x_dec = static_cast(ld_arg); const auto x_flt = static_cast(ld_arg); diff --git a/test/test_to_chars.cpp b/test/test_to_chars.cpp index 1a8f02d6a..52d1c2ca5 100644 --- a/test/test_to_chars.cpp +++ b/test/test_to_chars.cpp @@ -28,9 +28,9 @@ using namespace boost::decimal; static std::mt19937_64 rng(42); #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) -static constexpr auto N = static_cast(1024U); // Number of trials +static constexpr auto N = static_cast(1024); // Number of trials #else -static constexpr auto N = static_cast(1024U >> 4U); // Number of trials +static constexpr auto N = static_cast(1024 >> 4U); // Number of trials #endif // stringop overflow errors from gcc-13 and on with x86 diff --git a/test/test_zeta.cpp b/test/test_zeta.cpp index 9c98f779f..9a9c4543a 100644 --- a/test/test_zeta.cpp +++ b/test/test_zeta.cpp @@ -26,6 +26,7 @@ # pragma GCC diagnostic ignored "-Wconversion" # pragma GCC diagnostic ignored "-Wsign-conversion" # pragma GCC diagnostic ignored "-Wfloat-equal" +# pragma GCC diagnostic ignored "-Wuseless-cast" #endif // Windows in Github actions has a broken chrono header @@ -130,9 +131,9 @@ namespace local auto trials = static_cast(UINT8_C(0)); #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH) - constexpr auto count = (sizeof(decimal_type) == static_cast(UINT8_C(4))) ? static_cast(UINT32_C(0x80)) : static_cast(UINT32_C(0x20)); + constexpr auto count = (sizeof(decimal_type) == static_cast(UINT8_C(4))) ? UINT32_C(0x80) : UINT32_C(0x20); #else - constexpr auto count = (sizeof(decimal_type) == static_cast(UINT8_C(4))) ? static_cast(UINT32_C(0x10)) : static_cast(UINT32_C(0x4)); + constexpr auto count = (sizeof(decimal_type) == static_cast(UINT8_C(4))) ? UINT32_C(0x10) : UINT32_C(0x4); #endif for( ; trials < count; ++trials)