Daniel Lemire a7249f86ed replace checked re-parse with O(1) simdjson-style overflow check
The previous commit detects multi-wrap u64 overflow at the max_digits
boundary by re-parsing the digits through a checked multiply-add loop
(O(max_digits)). Replace that with the constant-time check used in
simdjson: the leading digit plus a single threshold comparison.

For a max_digits-length value, min_safe_u64(base) == base^(max_digits-1)
is the smallest such value and also the width of each leading-digit band
[d*ms, (d+1)*ms). Since that width is < 2^64, the only band that can
straddle 2^64 is d == dmax (the largest leading digit that still fits),
and there it straddles at most once, so a single threshold dmax*ms
separates wrapped from non-wrapped values. A leading digit above dmax
always overflows; below dmax always fits. dmax and the threshold derive
from the existing min_safe_u64 table, so no new tables are needed and
dmax*ms cannot itself overflow.

Add a programmatic, self-verifying test for parse_int_string overflow
detection covering bases 2..36, complementing the hand-picked strings
added earlier. Every generated input is cross-checked against an
independent trusted oracle (a plain 64-bit checked multiply-add); on
success the parsed value is also compared exactly and full consumption
of the input is asserted.

Per base it exercises:
  - an exact-boundary sweep of the 64 values straddling 2^64
    (UINT64_MAX-31 .. 2^64+31), built by walking the digit string;
  - UINT64_MAX, 2^64 and the all-max-digit value, each also with
    leading zeros;
  - random max_digits-length values across every leading digit, with
    the heaviest sampling on the lead == dmax band that straddles 2^64,
    and full coverage of lead > dmax (the multi-wrap region the naive
    min_safe check accepted by mistake);
  - max_digits-1 (never overflows) and max_digits+1 (always overflows).
A small signed (int64_t) section checks the exact INT64_MIN/INT64_MAX
limits round-trip and that INT64_MAX+1 / INT64_MIN-1 are rejected in
every base.
2026-06-13 21:34:34 -04:00
..
bloat_analysis harmonize files to use "east const" 2024-11-23 09:46:18 +01:00
build_tests formatted code 2024-12-01 16:39:28 +01:00
installation_tests harmonize files to use "east const" 2024-11-23 09:46:18 +01:00
basictest.cpp refactor verification calls for double and float limits 2026-02-04 15:36:31 +09:00
BUILD.bazel add char8_t test 2024-11-25 15:43:51 +01:00
CMakeLists.txt tests: parallelize the exhaustive midpoint sweep across hardware threads 2026-06-01 13:01:10 +01:00
example_comma_test.cpp harmonize files to use "east const" 2024-11-23 09:46:18 +01:00
example_integer_times_pow10.cpp fixed copy&paste error and minor mess 2025-09-29 19:54:25 +03:00
example_test.cpp make it build 2024-12-03 23:23:34 +01:00
exhaustive32_64.cpp tests: parallelize exhaustive32 and exhaustive32_64 sweeps too 2026-06-01 21:09:46 +01:00
exhaustive32_midpoint.cpp tests: parallelize the exhaustive midpoint sweep across hardware threads 2026-06-01 13:01:10 +01:00
exhaustive32.cpp tests: parallelize exhaustive32 and exhaustive32_64 sweeps too 2026-06-01 21:09:46 +01:00
fast_int.cpp replace checked re-parse with O(1) simdjson-style overflow check 2026-06-13 21:34:34 -04:00
fixedwidthtest.cpp Remove an unreachable return statement 2026-06-09 03:37:58 -04:00
fortran.cpp harmonize files to use "east const" 2024-11-23 09:46:18 +01:00
ipv4_test.cpp lint 2025-12-25 03:06:22 +05:30
json_fmt.cpp turning json option into macro parameter 2025-03-09 15:13:43 -04:00
long_exhaustive32_64.cpp Remove an else if statement that is always false 2026-06-09 03:48:54 -04:00
long_exhaustive32.cpp harmonize files to use "east const" 2024-11-23 09:46:18 +01:00
long_random64.cpp harmonize files to use "east const" 2024-11-23 09:46:18 +01:00
long_test.cpp init 2026-03-10 11:53:45 -04:00
p2497.cpp lint 2025-05-19 18:16:14 -04:00
powersoffive_hardround.cpp formatted code 2024-12-01 16:39:28 +01:00
random64.cpp harmonize files to use "east const" 2024-11-23 09:46:18 +01:00
random_string.cpp formatted code 2024-12-01 16:39:28 +01:00
rcppfastfloat_test.cpp harmonize files to use "east const" 2024-11-23 09:46:18 +01:00
short_random_string.cpp formatted code 2024-12-01 16:39:28 +01:00
string_test.cpp init 2026-03-10 11:53:45 -04:00
supported_chars_test.cpp add char8_t test 2024-11-25 15:43:51 +01:00
wide_char_test.cpp add failing test for wide chars 2024-11-21 00:08:55 +01:00