From: Adhemerval Zanella Date: Fri, 2 May 2025 17:59:13 +0000 (-0300) Subject: math: Fix UB on lroundl X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c949920ef65aedceaaa679a75cdbaafd110f0cc5;p=thirdparty%2Fglibc.git math: Fix UB on lroundl Building with --enable-ubasn triggers: $ math/test-ldouble-pow testing long double (without inline functions) UBSAN: Undefined behaviour in ../sysdeps/ieee754/ldbl-96/s_roundl.c:75:28 left shift of 1 by 31 cannot be represented in type 'int' Aborted --- diff --git a/sysdeps/ieee754/ldbl-96/s_roundl.c b/sysdeps/ieee754/ldbl-96/s_roundl.c index 91d0c445d8..8ec77218fb 100644 --- a/sysdeps/ieee754/ldbl-96/s_roundl.c +++ b/sysdeps/ieee754/ldbl-96/s_roundl.c @@ -72,7 +72,7 @@ __roundl (long double x) /* X is integral. */ return x; - uint32_t j = i1 + (1 << (62 - j0)); + uint32_t j = i1 + (1U << (62 - j0)); if (j < i1) { uint32_t k = i0 + 1;