fix(libc): hypot returns +inf when one operand is infinite #3429
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3429"
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 CouchRiv on 2026-10-11T10:25:00Z.
What
hypot(inf, NaN)returns a NaN onmain:C Annex F says
hypot(±∞, y)returns +∞ even ifyis a NaN, and FreeBSD msun checks the infinite operand first (e_hypot.c#L75-L79), so it also returns +∞ for a signalling NaN. The hoststd::hypotreturns a NaN for the signalling NaN.hypotnow returns +∞ when either operand is infinite; every other input still goes tostd::hypot.hypotfand the other functions do not change.Tested
CachyOS Linux, RTX 4070 Ti (NVIDIA) and Radeon 610M (RADV), lavapipe for CI parity.
hypot_nid_postfixchecks (±inf with a NaN, both orders) fail onmainand pass with the change; 1/1 on NVIDIA, RADV and lavapipe.tools/check_conventions.py --base origin/mainandgit diff --check: clean.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T10:35:49Z.
Checked against FreeBSD
e_hypot.c(Inf/NaN branch returns the infinite operand, also for a signalling NaN) and C Annex F;guest_mathpasses with the change and fails without it (negative check), full scoped ctest green. Merging.