ucrt: set ERANGE when scalbn and its relatives overflow #62
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!62
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/62/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 12:13 UTC · original
Repla09:fix/ucrt-scalbn-fdim-errno→main· +40 −8 · 2 files · 1 commits · merged 2026-11-26 13:26 UTCFollow-up to the scope note on #52:
scalbn,scalbnf,scalbln,scalblnfand_scalbreturned infinity on overflow without settingerrno, whileldexp(the same operation) setsERANGE, and Microsoft documentsERANGEforscalbnoverflow.They are now checked the same way as
ldexp; the float forms after rounding to a float, so a float overflow that is finite as a double counts.scalbn_and_its_relatives_set_erange_on_overflowfails on main (errno0, not 34). It covers all five, and checks that an in-range result and an infinity from an infinite argument leave a seedederrnoalone.fdimfstill sets noerrnoon overflow. Its fix depends on #52's float check, so it will follow once #52 is in.Testing
cargo test --target x86_64-apple-darwin -p victory-hlepasses (222 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 12:45 UTC · original · requested changes
Thanks, the logic matches
ldexpand the test fails on main. Please:ucrt/math.rs; keep both tests.errnobullet indocs/native-host.md(~303): listscalbn,scalbnf,scalbln,scalblnfand_scalbalongsideldexpf, leaving onlyfdimfas not setting errno yet.ERANGE), as withldexp.Optional:
ldexp/ldexpfcould call the newscalbn_checked/scalbnf_checkedhelpers instead of duplicating them.@Repla09 on GitHub · 2026-11-26 12:56 UTC · original
Thanks. In
1fd83c0, rebased on main:a_float_that_overflows_sets_erangefrom #52 as it was, andscalbn_and_its_relatives_set_erange_on_overflowbeside it.errnobullet in native-host.md listsscalbn,scalbnf,scalbln,scalblnfand_scalbwithldexpf, leaving onlyfdimf.errnoalone, and the test checks it (scalbn(1, -2000)andscalbnf(1, -200)give 0 with a seeded errno unchanged).Also took the optional one:
ldexp/ldexpfnow callscalbn_checked/scalbnf_checked.@LakshanSivakumar on GitHub · 2026-11-26 13:26 UTC · original · approved these changes
All review items are addressed cleanly (
scalbn_checked/scalbnf_checkedshared withldexp/ldexpf,docs/native-host.mdupdated including underflow behavior, both tests kept, and CI green). Merging.