ucrt: set ERANGE when a checked float wrapper or ldexpf overflows #52
No reviewers
Labels
No labels
accessibility
bug
claimed
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
tester report
urgent
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/LakshanSivakumar--Native-Victory-macOS!52
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/52/head"
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?
@Repla09 on GitHub · 2026-11-26 11:31 UTC · original
Repla09:fix/ucrt-float-overflow-errno→main· +29 −4 · 2 files · 2 commits · merged 2026-11-26 12:41 UTCThe math module sets
ERANGEfor an infinity from finite arguments (docs/native-host.md), but the float forms (expf,powf,coshf,hypotf,ldexpfand the rest made by theunary!/binary!macros) checked the double result before rounding it to a float. A float overflow is still finite as a double, soexpf(100)andldexpf(1, 200)returned infinity witherrnountouched, whileexp(1000)setERANGE.Now the result is checked after rounding it to the float it returns.
a_float_that_overflows_sets_erangefails without the fix (errno0, not 34) and checks five overflowing calls plus a finite one that leaveserrnoalone.Testing
cargo test --target x86_64-apple-darwin -p victory-hlepasses (220 unit, 15 native_probe; the D3D12 probe test skipped, no Metal Shader Converter here).x86_64-apple-darwinshows no new warnings;rustfmt --checkandcargo xtask policypass.@LakshanSivakumar on GitHub · 2026-11-26 11:42 UTC · original · requested changes
The five overflow cases all reproduce on main and pass here. Two things:
ldexpf, in the title and in the UCRT notes.fdimf,scalbnfandscalblnfstill return infinity without settingerrno. That predates this PR, so another PR or a mention is fine.errnobefore the success check and verify it survives. Also include a true infinity from an infinite input, so the test tells a valid infinity apart from an overflow.@Repla09 on GitHub · 2026-11-26 11:50 UTC · original
Thanks. Retitled to the checked float wrappers plus
ldexpf, and the UCRT notes say the same, mentioning thatfdimf,scalbnfandscalblnfstill set no errno (left for another PR). In 2315032 the test seeds errno = 7 and checks it survives a finite result and infinities from infinite inputs (expf(inf),powf(inf, 2),ldexpf(inf, 1)), so a valid infinity is told apart from an overflow. Rebased onto main.@LakshanSivakumar on GitHub · 2026-11-26 12:01 UTC · original · review (dismissed)
Thanks for addressing the earlier requests; the regression passes under Rosetta and fails against main. Approved.
@LakshanSivakumar on GitHub · 2026-11-26 12:09 UTC · original
Approved, but #51 just landed and both edit the UCRT
errnoparagraph indocs/native-host.md, so this now conflicts. Please rebase on main (or merge main in) and resolve that paragraph; I'll merge once CI is green.@Repla09 on GitHub · 2026-11-26 12:13 UTC · original
Rebased onto main after #51 merged: both added a sentence to the same
errnoline in native-host.md, so the conflict kept both (the remquo guarantee, then the float-wrapper rule). No code change.@LakshanSivakumar on GitHub · 2026-11-26 12:41 UTC · original · approved these changes
Thanks for the rebase. The docs paragraph now keeps both the remquo and the ERANGE sentences, and the code is unchanged. Approved.