ucrt: set ERANGE when scalbn and its relatives overflow #62
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/62"
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 LakshanSivakumar/Native-Victory-macOS. Originally posted by Repla09 on 2026-11-26T12:13:20Z.
Follow-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.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T12:45:32Z.
Review: CHANGES_REQUESTED
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.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Repla09 on 2026-11-26T12:56:15Z.
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.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T13:26:40Z.
Review: APPROVED
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.