From b3c0d56e76d9465af9610adb9cf1b577a10300c7 Mon Sep 17 00:00:00 2001 From: Junekey Jeon Date: Fri, 18 Sep 2020 10:04:40 -0700 Subject: [PATCH] Change msvc version of clz & clzll to match __builtin_clz & _builtin_clzll --- include/fmt/format.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index ca26e772..845e7c44 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -193,7 +193,7 @@ namespace detail { # ifndef __clang__ # pragma intrinsic(_BitScanReverse) # endif -inline uint32_t clz(uint32_t x) { +inline int clz(uint32_t x) { unsigned long r = 0; _BitScanReverse(&r, x); @@ -202,7 +202,7 @@ inline uint32_t clz(uint32_t x) { // "r", but the only way that can happen is if "x" is 0, // which the callers guarantee to not happen. FMT_SUPPRESS_MSC_WARNING(6102) - return 31 - r; + return 31 - static_cast(r); } # define FMT_BUILTIN_CLZ(n) detail::clz(n) @@ -210,7 +210,7 @@ inline uint32_t clz(uint32_t x) { # pragma intrinsic(_BitScanReverse64) # endif -inline uint32_t clzll(uint64_t x) { +inline int clzll(uint64_t x) { unsigned long r = 0; # ifdef _WIN64 _BitScanReverse64(&r, x); @@ -227,7 +227,7 @@ inline uint32_t clzll(uint64_t x) { // "r", but the only way that can happen is if "x" is 0, // which the callers guarantee to not happen. FMT_SUPPRESS_MSC_WARNING(6102) - return 63 - r; + return 63 - static_cast(r); } # define FMT_BUILTIN_CLZLL(n) detail::clzll(n) } // namespace detail