From 1d60cac326dc0f68f2a79048ecc7945e16cc9356 Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Mon, 5 May 2025 09:42:07 -0300 Subject: [PATCH] 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' --- sysdeps/ieee754/ldbl-128/s_lroundl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 -- 2.47.2