]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
math: Fix UB in lroundl
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Mon, 5 May 2025 12:42:07 +0000 (09:42 -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_lroundl.c:72:32 left shift of 562949953421312 by 14 cannot be represented in type 'long int'

sysdeps/ieee754/ldbl-128/s_lroundl.c

index b237b56b3875101630db86e6ad754f70556e3514..0b2ea462fb944a3114ac8167c896f9db8e5a2fe1 100644 (file)
@@ -69,7 +69,7 @@ __lroundl (_Float128 x)
            result = (long int) i0;
          else
            {
-             result = ((long int) i0 << (j0 - 48)) | (j >> (112 - j0));
+             result = (i0 << (j0 - 48)) | (j >> (112 - j0));
 #ifdef FE_INVALID
              if (sizeof (long int) == 8
                  && sign == 1