test(libc): cover pow special values and the signs of its zero and infinite results #15143
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15143"
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 Oscar45397 on 2026-11-02T18:23:12Z.
What
powhas no test.CheckPowSpecialValuesis added toguest_math_exact, one assertion group per rule of C11 F.10.4.4:pow(2, 10) == 1024,pow(-2, 3) == -8,pow(-2, 2) == 4,pow(2, -1) == 0.5;pow(x, +-0) == 1for any x including NaN and+inf;pow(1, y) == 1for any y including NaN and+-inf;pow(NaN, 1)andpow(2, NaN)are NaN;pow(+-0, y)for y an odd negative integer is+-inf; for y negative and not an odd integer (-2,-inf) it is+inf; for y an odd positive integer it is+-0with the sign of x; for y positive and not an odd integer (2, 0.5) it is+0;pow(-1, +-inf) == 1;pow(x, +inf)is+0for |x| < 1 and+inffor |x| > 1;pow(x, -inf)is the reverse;pow(+inf, y)is+0for y < 0 and+inffor y > 0;pow(-inf, y)is-0for y an odd negative integer,+0for other negative y,-inffor y an odd positive integer,+inffor other positive y;pow(-8, 0.5)andpow(-2, -1.5)(finite negative x, finite non-integer y) are NaN;pow(10, 400)overflows to+infandpow(10, -400)underflows to 0.errnois not asserted.Sources: C11 F.10.4.4 for every special value above; the overflow and underflow cases follow from DBL_MAX being about 1.8e308 and the smallest subnormal about 4.9e-324.
Changed:
core/libs/tests/GuestMathExact.cpp. Test only, no change to the library.Tested
Windows 11 Home 26200, Ryzen 9 5900X, WinLibs GCC 15.2.0 r7, Release, on
mainb28bb77217plus this test.ctest --test-dir build -R '^guest_math_exact$' --repeat until-fail:3: passes 3 of 3 runs.powcomputingstd::pow(std::fabs(base), exp),guest_math_exactfails. Restored, it passes again.python tools/check_conventions.py --base upstream/main: passed.Not run on Linux or macOS.
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)🤖 Generated with Claude Code
Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-02T19:45:33Z.
Review: APPROVED
The special cases are the C99 Annex F
powtable, includingpow(x, ±0) = 1for NaNx,pow(+1, y) = 1for NaNy, the signed zeros and infinities frompow(±0, y)andpow(-∞, y)by odd/even integery,pow(-1, ±∞) = 1, and NaN for a negative finite base with a non-integer exponent. Tested on Windows 11, WinLibs GCC 15.2.0, with this head merged ontomain:guest_math_exactpasses.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T12:56:27Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this test-only change; the reviewed assertions align with the stated
powspecial-value cases.What I ran
Read the prepared diff and the full changed file at head
c1832d8e2438615b71f2142bcf846dc4b0c6ac85usingrepo_read.py. I did not run tests or other commands.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
Tests and conventions checks reported in the PR description were not run by me. No files were excluded from review:
core/libs/tests/GuestMathExact.cppwas included in the prepared bundle and read in full. The review bundle did not providefiles.json; exclusion status beyond the manifest was not verified. No other repository files were read.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-27T21:32:49Z.
Review: APPROVED
Reviewed — looks good
Nothing in the reviewed test change blocks merging; the assertions exercise the stated
powspecial values and signed results.What I ran
Reviewed head
6ebaab5c69623a16995ce6bffe1d26b52d16427b. No commands or tests were run;repo_read.pywas unavailable as an executable tool in this session. The author reports three passingguest_math_exactruns and a passing conventions check; those were not independently run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The manifest lists
core/libs/tests/GuestMathExact.cppas reviewed and included; its relevant changed function, invocation, and includes were read. No other changed files were listed. No runtime, build, or conventions checks were performed; the reported test environment was Windows 11 with GCC 15.2.0. Linux, macOS, and console behavior were not verified.To get this to a good state
Nothing is required.