From 548118a7354f48558e402f4c843471792dcb7ec8 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Thu, 27 Oct 2022 20:44:43 -0700 Subject: [PATCH 1/3] Fix warning C4146: unary minus operator applied to unsigned type --- include/boost/math/ccmath/isinf.hpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/include/boost/math/ccmath/isinf.hpp b/include/boost/math/ccmath/isinf.hpp index 15787c25bc..a07b42aabd 100644 --- a/include/boost/math/ccmath/isinf.hpp +++ b/include/boost/math/ccmath/isinf.hpp @@ -14,11 +14,18 @@ namespace boost::math::ccmath { template -inline constexpr bool isinf(T x) +constexpr bool isinf(T x) noexcept { if(BOOST_MATH_IS_CONSTANT_EVALUATED(x)) { - return x == std::numeric_limits::infinity() || -x == std::numeric_limits::infinity(); + if constexpr (std::is_signed_v) + { + return x == std::numeric_limits::infinity() || -x == std::numeric_limits::infinity(); + } + else + { + return x == std::numeric_limits::infinity(); + } } else { From 2acd1d62bfa2af2da00d111ffd48fa2b1db6ace1 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Thu, 27 Oct 2022 20:47:09 -0700 Subject: [PATCH 2/3] Fix warning C4244: 'return': conversion from 'int' to 'T' --- include/boost/math/ccmath/logb.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/math/ccmath/logb.hpp b/include/boost/math/ccmath/logb.hpp index 1b0c165bcc..4df96dd443 100644 --- a/include/boost/math/ccmath/logb.hpp +++ b/include/boost/math/ccmath/logb.hpp @@ -29,7 +29,7 @@ inline constexpr T logb_impl(T arg) noexcept int exp = 0; boost::math::ccmath::frexp(arg, &exp); - return exp - 1; + return static_cast(exp - 1); } } // Namespace detail From 94201a88ba29fc34bec6498926f0db91d190e458 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Fri, 28 Oct 2022 07:55:34 -0700 Subject: [PATCH 3/3] Use numeric_limits::is_signed to support Boost.MP types --- include/boost/math/ccmath/isinf.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/math/ccmath/isinf.hpp b/include/boost/math/ccmath/isinf.hpp index a07b42aabd..9df492a18a 100644 --- a/include/boost/math/ccmath/isinf.hpp +++ b/include/boost/math/ccmath/isinf.hpp @@ -18,7 +18,7 @@ constexpr bool isinf(T x) noexcept { if(BOOST_MATH_IS_CONSTANT_EVALUATED(x)) { - if constexpr (std::is_signed_v) + if constexpr (std::numeric_limits::is_signed) { return x == std::numeric_limits::infinity() || -x == std::numeric_limits::infinity(); }