fix(libc): set ERANGE for decimal subnormals in wcstod as strtod does #11892
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11892"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-27T11:55:41Z.
What
strtodsetsERANGEfor a decimal input whose result is a nonzero subnormal (#9833).wcstodparses through the hoststrtoddirectly, so it skips that rule and leaveserrnoalone. Thewcstodof thelibc.prxthat titles ship setsERANGEin the same cases as itsstrtod.wcstodnow parses throughstrtod, as #9833 offered as a follow-up.Tested
Windows 11 Enterprise 10.0.22621, Ryzen 9 5950X, WinLibs GCC 15.2.0 UCRT r7, Ninja, Release,
BUILD_TESTING=ON,main8ff4baf534.libc.prxof eleven titles natively: PPSA04158, PPSA05916, PPSA07923, PPSA09614, PPSA13934, PPSA20423, PPSA25636, PPSA26528, PPSA33655, PPSA34008 and PPSA35169.Measured cases:
errno1e-310000012688b70e62bERANGE-4.9406564584124654e-3248000000000000001ERANGE1e-3300ERANGE2.2250738585072014e-30800100000000000000x1p-107410x1.8p-10751ERANGE-0x1.000001p-10758000000000000001ERANGETheir
wcstodgives these results, and all eleven setERANGEfor1e-310,4.9406564584124654e-324and0x1.8p-1075.Random strings: 100,000 random decimal strings in the subnormal range (exponents -300 to -329) went through PPSA07923's
wcstodandmain's.maindiffers on 40,900, every one inerrno.strtodmatches on all 100,000, which shows the rulewcstodnow reuses.guest_math:CheckFloatUnderflowErrnogains the sevenwcstodcases above.guest_mathandguest_wide_stringspass in three runs out of three on the exact head.main'sStrings.cppand these tests,guest_mathaborts (exit 0xc0000409).python tools/check_conventions.py --base origin/mainandgit diff --checkpass.libSceLibcInternal.sprxwcstod(the debt entry keeps that as unmeasured), Linux and macOS (the change is target-independent).Current Linux qualification (2026-10-28)
Rebased onto
main2227f1366188cda5699dd20e2e756a18006a5d4b. Linux CPU validation on 2026-10-28 at6219aaaff1520be4d484d6b618c3c3977024be58(Arch Linux 7.2.9, AMD Ryzen 9 7950X, GCC 16.2.1, Ninja Release, BUILD_TESTING=ON).libc,guest_math_testsandguest_math_exact_testsrebuilt from this exact source.guest_mathandguest_math_exacteach passed three consecutive runs (6/6, no skips); the same two suites each passed three runs on the pinned main (6/6). Conventions and whitespace checks pass.Exact source pins, preservation proofs, dependency checks, build logs and JUnit, SHA-256
1176269c9e6948b5252a5db9e660978d7f978fb2d9f4ed6c68bc050b10b5ae68. This is focused Linux CPU qualification; earlier Windows/title/reference measurements retain their original pins. No new title or performance result is claimed.Current Linux qualification — 2026-10-29
Refreshed against main
5454cd2e455994d992aca39335ce60507eeda1eb.Linux qualification at
f6ca8993e813d818781a29f86148c52f58df4d4b(Arch Linux 7.2.9, Ryzen 9 7950X, GCC 16.2.1, Ninja Release, BUILD_TESTING=ON):guest_math,guest_math_exact,guest_dinkumware_internals,guest_wide_strings,guest_strtod_subnormal,guest_wide_conversioneach pass three consecutive runs (18/18, no skips). Thepublic_headersaudit passes at this exact head. All tracked public-header files match the pinned main; the affected test targets rebuild against those headers. Conventions and whitespace checks pass. The same focused groups passed three times on the pinned main.The combined debt entry retains the decimal wcstod qualification, the PPSA08329-only hexadecimal measurements and glibc 2.35 rounding limitation from merged #12291, with console wcstod still unmeasured. The focused set includes inherited hexadecimal-underflow cases and wide-string conversions. No new title measurements are claimed.
Evidence: immutable Linux qualification bundle. Its SHA-256 is
53b095da2f67f55b8aa56ba273681e0330fb39739be844458038dde410fb8cc4. No fresh Windows runtime execution is claimed; older measurements retain their recorded source pins.AI-assisted: yes (Codex).
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-27T12:03:27Z.
Review: APPROVED
I reviewed the delegation and the errno rule:
wcstodstill parses the ASCII prefix and mapsendptrthroughParseAsciiPrefix, while the delegatedstrtod_nid_postfixadds the same decimal nonzero-subnormalERANGEbehavior asstrtod. I built and ranguest_mathon native Linux using this PR's exactStrings.cppandGuestMath.cppchanges; 1/1 passed. The hosted Windows build also passes, along with conventions and the Linux relinker checks. I found no blocking issue in this focused change. The consolelibSceLibcInternalbehavior remains explicitly documented as unmeasured.