]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
math: Fix UB in ldbl-128 nearbyintl
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Mon, 5 May 2025 12:45:48 +0000 (09:45 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Thu, 8 May 2025 12:25:49 +0000 (09:25 -0300)
UBSAN: Undefined behaviour in ../sysdeps/ieee754/float128/../ldbl-128/s_nearbyintl.c:61:4 left shift of 1 by 63 cannot be represented in type 'long int'

sysdeps/ieee754/ldbl-128/s_nearbyintl.c

index d76d0155ad21a837371a9ff7e55254415e5e6d2a..b72ca2f01638dfda7ce573506336d311bd0ee49f 100644 (file)
@@ -42,7 +42,8 @@ __nearbyintl (_Float128 x)
                 L(-5.19229685853482762853049632922009600E+33)  /* 0xC06F000000000000, 0 */
   };
   fenv_t env;
-  int64_t i0, j0, sx;
+  int64_t i0, j0;
+  uint64_t sx;
   uint64_t i1 __attribute__ ((unused));
   _Float128 w, t;
   GET_LDOUBLE_WORDS64 (i0, i1, x);