From a2c05a10ec875712bfee739a05ed99fc3915f4e9 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Wed, 25 Jan 2023 10:34:28 +1300 Subject: [PATCH] Workaround a bug in MSVC <= 19.22 --- include/fmt/format-inl.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index 523fd514f972..a4bf1edb601d 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -174,8 +174,6 @@ FMT_CONSTEXPR inline uint64_t rotr(uint64_t n, uint32_t r) noexcept { return (n >> r) | (n << (64 - r)); } - - // Implementation of Dragonbox algorithm: https://github.com/jk-jeon/dragonbox. namespace dragonbox { // Computes upper 64 bits of multiplication of a 32-bit unsigned integer and a @@ -1021,8 +1019,7 @@ template <> struct cache_accessor { {0xe4d5e82392a40515, 0x0fabaf3feaa5334b}, {0xb8da1662e7b00a17, 0x3d6a751f3b936244}, {0x95527a5202df0ccb, 0x0f37801e0c43ebc9}, - { 0xf13e34aabb430a15, - 0x647726b9e7c68ff0 } + {0xf13e34aabb430a15, 0x647726b9e7c68ff0} #endif }; @@ -1144,7 +1141,8 @@ FMT_INLINE int remove_trailing_zeros(uint32_t& n) noexcept { // Modular inverse of 5 (mod 2^32): (mod_inv_5 * 5) mod 2^32 = 1. // See https://github.com/fmtlib/fmt/issues/3163 for more details. const uint32_t mod_inv_5 = 0xcccccccd; - const uint32_t mod_inv_25 = mod_inv_5 * mod_inv_5; + // Casts are needed to workaround a bug in MSVC 19.22 and older. + const uint32_t mod_inv_25 = uint32_t(uint64_t(mod_inv_5) * mod_inv_5); int s = 0; while (true) {