From bdd8abc6d6a93ce3ab8ad5db716222ee3110c4a3 Mon Sep 17 00:00:00 2001 From: "Pedro F. Giffuni" Date: Mon, 7 Jan 2019 17:35:09 +0000 Subject: [PATCH] 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) --- lib/msun/src/e_pow.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/msun/src/e_pow.c b/lib/msun/src/e_pow.c index 69ddb7ffcb48..52b2f5cebdbc 100644 --- a/lib/msun/src/e_pow.c +++ b/lib/msun/src/e_pow.c @@ -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);