From 48fc5404d4184111c0c771f4c1e841f652a532fd Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Thu, 18 Sep 2025 07:44:05 -0600 Subject: [PATCH] compatibility fix --- include/fast_float/float_common.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/include/fast_float/float_common.h b/include/fast_float/float_common.h index 2b8a528..e14c7dc 100644 --- a/include/fast_float/float_common.h +++ b/include/fast_float/float_common.h @@ -1132,13 +1132,10 @@ template constexpr uint64_t int_luts::min_safe_u64[]; template fastfloat_really_inline constexpr uint8_t ch_to_digit(UC c) { + // wchar_t and char can be signed, so we need to be careful. using UnsignedUC = typename std::make_unsigned::type; - auto uc = static_cast(c); - // For types larger than one byte, we need to force an index with sentinel - // value (using index zero because that is easiest) if any byte other than - // the low byte is non-zero. - auto mask = static_cast(-((uc & ~0xFFull) == 0)); - return int_luts<>::chdigit[static_cast(uc & mask)]; + return int_luts<>::chdigit[static_cast(static_cast(c) + & static_cast(-((static_cast(c) & ~0xFFull) == 0)))]; } fastfloat_really_inline constexpr size_t max_digits_u64(int base) {