pow(3): Workaround possible signed shift Undefined Behavior.

j is int32_t and thus j<<31 is undefined if j==1.

Hinted by:	muusl-lib (git 688d3da0f1730daddbc954bbc2d27cc96ceee04c)
Discussed with:	freebsd-numerics (kargl)
This commit is contained in:
Pedro F. Giffuni 2019-01-07 17:35:09 +00:00
parent ed47d82f59
commit bdd8abc6d6
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=342851

View File

@ -133,7 +133,7 @@ __ieee754_pow(double x, double y)
k = (iy>>20)-0x3ff; /* exponent */
if(k>20) {
j = ly>>(52-k);
if((j<<(52-k))==ly) yisint = 2-(j&1);
if(((u_int32_t)j<<(52-k))==ly) yisint = 2-(j&1);
} else if(ly==0) {
j = iy>>(20-k);
if((j<<(20-k))==iy) yisint = 2-(j&1);