mirror of
https://git.musl-libc.org/git/musl
synced 2025-02-15 09:43:57 +03:00
math: fix pow signed shift ub
j is int32_t and thus j<<31 is undefined if j==1, so j is changed to uint32_t locally as a quick fix, the generated code is not affected. (this is a strict conformance fix, future c standard may allow 1<<31, see DR 463. the bug was inherited from freebsd fdlibm, the proper fix is to use uint32_t for all bit hacks, but that requires more intrusive changes.) reported by Daniel Sabogal
This commit is contained in:
parent
87643335ac
commit
688d3da0f1
@ -125,11 +125,11 @@ double pow(double x, double y)
|
||||
else if (iy >= 0x3ff00000) {
|
||||
k = (iy>>20) - 0x3ff; /* exponent */
|
||||
if (k > 20) {
|
||||
j = ly>>(52-k);
|
||||
uint32_t j = ly>>(52-k);
|
||||
if ((j<<(52-k)) == ly)
|
||||
yisint = 2 - (j&1);
|
||||
} else if (ly == 0) {
|
||||
j = iy>>(20-k);
|
||||
uint32_t j = iy>>(20-k);
|
||||
if ((j<<(20-k)) == iy)
|
||||
yisint = 2 - (j&1);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user