[Bug 296791] powl returns wrong sign
[email protected] Tue, 14 Jul 2026 17:11:50 +0000
| Newsgroups | gmane.os.freebsd.devel.standards |
|---|---|
| Message-ID | <[email protected]/bugzilla/> |
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D296791
Bug ID: 296791
Summary: powl returns wrong sign
Product: Base System
Version: 15.1-RELEASE
Hardware: amd64
OS: Any
Status: New
Severity: Affects Many People
Priority: ---
Component: standards
Assignee: [email protected]
Reporter: [email protected]
Attachment #272844 text/plain
mime type:
Created attachment 272844
--> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D272844&action=
=3Dedit
reproducible example
C23 =C2=A77.12.1 p5:
> A floating result overflows if a finite result value with ordinary accura=
cy would have magnitude
> (absolute value) too large for the representation with full precision in =
the specified type. A result
> that is exactly an infinity does not overflow. If a floating result overf=
lows and default rounding
> is in effect, then the function returns the value of the macro HUGE_VAL, =
HUGE_VALF, or HUGE_VALL
> according to the return type, **with the same sign as the correct value o=
f the function.**
However, when an overflow or an underflow occurs in powl, it returns a wrong
sign in some patterns.
Wrong patterns:
powl(-3.0L, odd) =3D inf should be -inf
powl(-1.0L / 3.0L, odd) =3D 0 should be -0
powl(-3.0L, -odd) =3D 0 should be -0
powl(-1.0L / 3.0L, -odd) =3D inf should be -inf
Correct patterns:
powl(3.0L, even) =3D inf should be inf
powl(INFINITY, even) =3D inf should be inf
powl(3.0L, odd) =3D inf should be inf
powl(INFINITY, odd) =3D inf should be inf
powl(1.0L / 3.0L, even) =3D 0 should be 0
powl(1.0L / INFINITY, even) =3D 0 should be 0
powl(1.0L / 3.0L, odd) =3D 0 should be 0
powl(1.0L / INFINITY, odd) =3D 0 should be 0
powl(-3.0L, even) =3D inf should be inf
powl(-INFINITY, even) =3D inf should be inf
powl(-INFINITY, odd) =3D -inf should be -inf
powl(-1.0L / 3.0L, even) =3D 0 should be 0
powl(-1.0L / INFINITY, even) =3D 0 should be 0
powl(-1.0L / INFINITY, odd) =3D -0 should be -0
powl(3.0L, -even) =3D 0 should be 0
powl(INFINITY, -even) =3D 0 should be 0
powl(3.0L, -odd) =3D 0 should be 0
powl(INFINITY, -odd) =3D 0 should be 0
powl(1.0L / 3.0L, -even) =3D inf should be inf
powl(1.0L / INFINITY, -even) =3D inf should be inf
powl(1.0L / 3.0L, -odd) =3D inf should be inf
powl(1.0L / INFINITY, -odd) =3D inf should be inf
powl(-3.0L, -even) =3D 0 should be 0
powl(-INFINITY, -even) =3D 0 should be 0
powl(-INFINITY, -odd) =3D -0 should be -0
powl(-1.0L / 3.0L, -even) =3D inf should be inf
powl(-1.0L / INFINITY, -even) =3D inf should be inf
powl(-1.0L / INFINITY, -odd) =3D -inf should be -inf
You can easily reproduce the issue with the attached file.
> clang -lm test.c
> ./a.out
--=20
You are receiving this mail because:
You are the assignee for the bug.=