From eb584f748ed05d252bde62859b854f40838f4345 Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Sun, 28 Jan 2024 13:29:55 -0500 Subject: [PATCH] explicit cast --- include/fast_float/ascii_number.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/fast_float/ascii_number.h b/include/fast_float/ascii_number.h index 219c7d3c..15a8a20f 100644 --- a/include/fast_float/ascii_number.h +++ b/include/fast_float/ascii_number.h @@ -529,8 +529,8 @@ from_chars_result_t parse_int_string(UC const* p, UC const* pend, T& value, // this weird workaround is required because: // - converting unsigned to signed when its value is greater than signed max is UB pre-C++23. // - reinterpret_casting (~i + 1) would work, but it is not constexpr - // this is always optimized into a neg instruction. - value = T(-std::numeric_limits::max() - T(i - std::numeric_limits::max())); + // this is always optimized into a neg instruction (note: T is an integer type) + value = T(-std::numeric_limits::max() - T(i - uint64_t(std::numeric_limits::max()))); #ifdef FASTFLOAT_VISUAL_STUDIO #pragma warning(pop) #endif