]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
math: Fix UB in ldbl-128 powl
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Mon, 5 May 2025 13:48:40 +0000 (10:48 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Thu, 8 May 2025 12:25:49 +0000 (09:25 -0300)
testing _Float128 (without inline functions)
UBSAN: Undefined behaviour in ../sysdeps/ieee754/float128/../ldbl-128/e_powl.c:439:11 left shift of 4294953849 by 16 cannot be represented in type 'int'

sysdeps/ieee754/ldbl-128/e_powl.c

index 4e20616705633885c661f4bda3175aac7adc0375..cec2e9990bdafa0ede2f97ccbb6462b2140c3b57 100644 (file)
@@ -436,7 +436,7 @@ __ieee754_powl (_Float128 x, _Float128 y)
   z = one - (r - z);
   o.value = z;
   j = o.parts32.w0;
-  j += (n << 16);
+  j += ((uint32_t)n << 16);
   if ((j >> 16) <= 0)
     {
       z = __scalbnl (z, n);    /* subnormal output */