From a126b4d888dbdf254bc2b11fab8a5195951549f5 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Tue, 11 Jan 2022 08:23:30 -0800 Subject: [PATCH] Check if right shift is arithmetic --- include/fmt/format-inl.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index 2c51c50a..b2992e0c 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -907,6 +907,7 @@ inline uint64_t umul96_lower64(uint32_t x, uint64_t y) FMT_NOEXCEPT { // https://fmt.dev/papers/Grisu-Exact.pdf#page=5, section 3.4. inline int floor_log10_pow2(int e) FMT_NOEXCEPT { FMT_ASSERT(e <= 1700 && e >= -1700, "too large exponent"); + static_assert((-1 >> 1) == -1, "right shift is not arithmetic"); const int shift = 22; return (e * static_cast(log10_2_significand >> (64 - shift))) >> shift; }