From d633ecb2970ef31d5ba0fc89a0384fde3efd2b7d Mon Sep 17 00:00:00 2001 From: HedgehogInTheCPP Date: Sat, 19 Sep 2026 21:11:26 +0300 Subject: [PATCH] Fix JSON parsing error. Remove FASTFLOAT_CONSTEXPR17 from json_fmt because it's a template parameter. --- include/fast_float/ascii_number.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/include/fast_float/ascii_number.h b/include/fast_float/ascii_number.h index c57a071..5cf2a74 100644 --- a/include/fast_float/ascii_number.h +++ b/include/fast_float/ascii_number.h @@ -533,7 +533,7 @@ parse_number_string(UC const *p, UC const *pend, *p == UC('+'))) { ++p; - if FASTFLOAT_CONSTEXPR17 (json_fmt) { + if (json_fmt) { if (p == pend && !is_integer(*p)) { // A sign must be followed by an integer return report_parse_error(answer, p, @@ -575,25 +575,24 @@ parse_number_string(UC const *p, UC const *pend, answer.integer = span(start_digits, digit_count); } #ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN - if FASTFLOAT_CONSTEXPR17 (json_fmt) { -#ifndef FASTFLOAT_ISNOT_CHECKED_BOUNDS + if (json_fmt) { // At least 1 digit in integer part if (digit_count == 0) { return report_parse_error(answer, p, parse_error::no_digits_in_integer_part); } -#endif } if (json_fmt || chars_format_t(options.format & detail::javascript_fmt)) { // ECMAScript DecimalIntegerLiteral is "0" or a non-zero digit followed by // digits: no leading zeros. Unlike JSON, the integer part may be empty // (".5"); the no_digits_in_mantissa check below still rejects ".". if (start_digits[0] == UC('0') && digit_count > 1) { - if (!chars_format_t(options.format & detail::javascript_sloppy_fmt)) { + if (json_fmt || + !chars_format_t(options.format & detail::javascript_sloppy_fmt)) { return report_parse_error( answer, start_digits, parse_error::leading_zeros_in_integer_part); } - if FASTFLOAT_CONSTEXPR17 (!json_fmt) { + if (!json_fmt) { // Sloppy mode (Annex B): a NonOctalDecimalIntegerLiteral has a leading // zero and at least one digit that is 8 or 9 ("08.5" is 8.5). With // octal digits only, it is a LegacyOctalIntegerLiteral ("0775"), which @@ -629,7 +628,7 @@ parse_number_string(UC const *p, UC const *pend, digit_count -= static_cast(answer.exponent); } #ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN - if FASTFLOAT_CONSTEXPR17 (json_fmt) { + if (json_fmt) { // At least 1 digit in fractional part if (has_decimal_point && answer.exponent == 0) { return report_parse_error(answer, p,