From c949920ef65aedceaaa679a75cdbaafd110f0cc5 Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Fri, 2 May 2025 14:59:13 -0300 Subject: [PATCH] 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 --- sysdeps/ieee754/ldbl-96/s_roundl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; -- 2.47.2