Repository navigation
fix(libc): keep frexp from raising FE_INVALID for a signaling NaN - #4946
ErenYeager1836 wants to merge 1 commit into
Conversation
|
Windows test of this PR. Environment: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, Result: guest_math (1 of 1; the test file is shared with #4942, both merged together) pass. Not checked: whether the test fails without the change in the library code; the PR was not tested alone, only in the combined merge (the tests of the other PRs in the batch also pass); no title run; Linux not tested. AI-assisted (Claude Code). |
919963b to
f24f7ee
Compare
f24f7ee to
c33caa0
Compare
|
Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line. |
What
Under IEEE 754 and FreeBSD's
s_frexp.cands_frexpf.c(libm),frexpandfrexpfstore 0 in*expfor zero, infinity, and NaN and return the argument unchanged without raising theFE_INVALIDfloating-point exception for a signaling NaN.In
core/libs/prx/libc/src/Math.cpp,frexpandfrexpfforwarded directly to hoststd::frexp. On hosts wherestd::frexpevaluates floating-point arguments via FPU operations, passing a signaling NaN can raiseFE_INVALID, and*expis left unspecified by C17 7.12.6.4 for infinity and NaN.This change:
std::memcpyinto integer words) to identify zero, infinity, and NaN without tripping host floating-point exception traps on signaling NaNs.*exponentand returns the argument unchanged for these special values as FreeBSD libm does.GuestMath.cpp(CheckFrexpSpecialValues).docs/dev/debt/libc.md.Tested
GuestMath.cppunit tests.python tools/check_conventions.py --base upstream/mainpasses with no violations.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)