From 9dbcaa293b79f88efcd03a8e041bb4ee69721cb6 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Tue, 28 Mar 2023 14:31:37 +0200 Subject: [PATCH] Fix MSVC warnings --- include/boost/charconv/detail/floff.hpp | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/include/boost/charconv/detail/floff.hpp b/include/boost/charconv/detail/floff.hpp index 768bb75..f7b947e 100644 --- a/include/boost/charconv/detail/floff.hpp +++ b/include/boost/charconv/detail/floff.hpp @@ -58,6 +58,12 @@ #include #endif +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable: 4127) // Extensive use of BOOST_IF_CONSTEXPR emits warnings under C++11 and 14 +# pragma warning(disable: 4554) // parentheses are used be warning is still emitted +#endif + namespace jkj { namespace floff { namespace detail { template @@ -2535,13 +2541,13 @@ namespace jkj { namespace floff { segment32 *= 100; } - std::uint64_t prod; + std::uint64_t prod_64 {}; if (remaining_digits == 1) { - prod = (segment32 * std::uint64_t(1441151882)) >> 25; - current_digits = std::uint32_t(prod >> 32); + prod_64 = (segment32 * std::uint64_t(1441151882)) >> 25; + current_digits = std::uint32_t(prod_64 >> 32); if (check_rounding_condition_inside_subsegment( - current_digits, std::uint32_t(prod), 8, has_more_segments)) { + current_digits, std::uint32_t(prod_64), 8, has_more_segments)) { if (++current_digits == 10) { *buffer = '1'; ++buffer; @@ -2553,11 +2559,11 @@ namespace jkj { namespace floff { ++buffer; } else { - prod = (segment32 * std::uint64_t(450359963)) >> 29; - current_digits = std::uint32_t(prod >> 32); + prod_64 = (segment32 * std::uint64_t(450359963)) >> 29; + current_digits = std::uint32_t(prod_64 >> 32); if (check_rounding_condition_inside_subsegment( - current_digits, std::uint32_t(prod), 7, has_more_segments)) { + current_digits, std::uint32_t(prod_64), 7, has_more_segments)) { if (++current_digits == 100) { std::memcpy(buffer, "1.0", 3); buffer += 3; @@ -4706,6 +4712,10 @@ case n: } }} // Namespace jkj::floff +#ifdef BOOST_MSVC +# pragma warning(pop) +#endif + #undef JKJ_UNRECHABLE #undef JKJ_SAFEBUFFERS #undef JKJ_HAS_BUILTIN