fix(libc): honor strtod flush-to-zero with DAZ enabled #28284
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/28284"
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 ibrahimmaq14 on 2026-11-29T18:35:14Z.
What
Addresses the
guest_strtod_subnormalfailure in #27647. Apple Clang optimized the masked nonzero check into a floating-point comparison. With MXCSR denormals-are-zero enabled, that comparison sees a subnormal as zero and the flush-to-zero branch is skipped.Compare the unsigned significand and exponent bits as a single range between zero and the smallest normal double. When FTZ is enabled and the magnitude is in that range, return signed zero with
ERANGE. Add a negative decimal case for bothstrtodandwcstod.Tested
GuestStrtodSubnormal.cpptest withStrings.cppat-O3 -DNDEBUG. The test aborts onmainat “FTZ flushes an inexact decimal subnormal” and passes with this change.libc/src/exception/Runtime.cppbecause the macOS C++ ABI headers lack__class_type_info::__contained_virtual_maskand related members.tools/check_conventions.pyandgit diff --checkpassed. I compared both changed files against the open PRs and found no overlapping edits.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)Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-29T18:38:20Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
8a70bddf1e:tools/check_conventions.pypassed.guest_strtod_subnormal_testsbuilt cleanly.guest_strtod_subnormal):core/libs/prx/libc/src/Strings.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-29T18:44:39Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the inspected implementation compares the parsed double’s magnitude bits to the normal-range boundary and returns a zero carrying the original sign when flush-to-zero is enabled.
What I ran
8a70bddf1e137336045fb9f49c29b467e0cc2f72and the prepared diff; no checks were run.core/libs/prx/libc/src/Strings.cpp(lines 525–610) andcore/libs/tests/GuestStrtodSubnormal.cpp(full file). The full text of both changed files was included; no changed files were excluded.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The author-reported test and convention-check results were not independently run or confirmed.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by NobleBrains on 2026-11-30T23:53:42Z.
Review: APPROVED
Confirmed on macOS 15.
Setup: Apple M4, macOS 15.7.9, Apple clang 17.0.0 (clang-1700.6.3.2), x86_64 Release under Rosetta,
BUILD_TESTING=ON. These are the OS and compiler generation of themacos-15runner; the description tested macOS 27.Tree:
main93d64f2d1e+ the open macOS build fixes #27201, #27739, #27843, #17425, #27827, #27767 (maindoes not build on macOS without them, see #28168) + #22091 + #28369, then #28075, #28076 and #28284 merged one after another. Each merged cleanly.guest_strtod_subnormal8a70bddf1eFull
ctest -j 6with all of them merged: 7038/7066 pass. Compared with the same tree before these PRs, no test fails that passed before.jsc_wtf_cpu_timeaborted once under the parallel load, then passed 5/5 on its own; it is unrelated JavaScriptCore CPU-time code.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T06:03:52Z.
Review: COMMENTED
Built and ran the complete
GuestStrtodSubnormalfixture on Linux at8a70bddf1e. The setup tested subnormal results with the MXCSR flush-to-zero and denormals-are-zero settings, including the newly covered call with both settings enabled. The existing parsing and end-pointer cases also passed.AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.