From: Adhemerval Zanella Date: Mon, 5 May 2025 12:42:07 +0000 (-0300) Subject: math: Fix UB in lroundl X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1d60cac326dc0f68f2a79048ecc7945e16cc9356;p=thirdparty%2Fglibc.git math: Fix UB in lroundl 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' --- diff --git a/sysdeps/ieee754/ldbl-128/s_lroundl.c b/sysdeps/ieee754/ldbl-128/s_lroundl.c index b237b56b38..0b2ea462fb 100644 --- a/sysdeps/ieee754/ldbl-128/s_lroundl.c +++ b/sysdeps/ieee754/ldbl-128/s_lroundl.c @@ -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