]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
math: Fix UB in ldbl-128 roundl
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Mon, 5 May 2025 13:45:15 +0000 (10:45 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Thu, 8 May 2025 12:25:49 +0000 (09:25 -0300)
$ math/test-float128-cospi
testing _Float128 (without inline functions)
UBSAN: Undefined behaviour in ../sysdeps/ieee754/float128/../ldbl-128/s_roundl.c:75:30 left shift of 1 by 63 cannot be represented in type 'long long int'

sysdeps/ieee754/ldbl-128/s_roundl.c

index 9a87a463e89547ff15189418c31847e580bc4600..aa02e3c9c632f8431a4ef5e78eea23d0a99720ac 100644 (file)
@@ -72,7 +72,7 @@ __roundl (_Float128 x)
        /* X is integral.  */
        return x;
 
-      uint64_t j = i1 + (1LL << (111 - j0));
+      uint64_t j = i1 + (1ULL << (111 - j0));
       if (j < i1)
        i0 += 1;
       i1 = j;