]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
math: Fix UB in test-canonical-ldbl-96.c
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 22 Apr 2025 18:57:10 +0000 (15:57 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Wed, 7 May 2025 17:21:21 +0000 (14:21 -0300)
UBSAN: Undefined behaviour in ../sysdeps/ieee754/ldbl-96/test-canonical-ldbl-96.c:97:7 left shift of 1 by 31 cannot be represented in type 'int'

sysdeps/ieee754/ldbl-96/test-canonical-ldbl-96.c

index 898bea9fd1ef7902dd5504d957ecd3d1612f0dfe..707e5fa7c41d35011883d968f0b11ed1aa4cfe73 100644 (file)
@@ -95,7 +95,8 @@ do_test (void)
     {
       long double ld;
       SET_LDOUBLE_WORDS (ld, tests[i].exponent | (tests[i].sign << 15),
-                        (tests[i].mantissa >> 32) | (tests[i].high << 31),
+                        (tests[i].mantissa >> 32)
+                        | ((uint32_t)tests[i].high << 31),
                         tests[i].mantissa & 0xffffffffULL);
       bool canonical = iscanonical (ld);
       if (canonical == tests[i].canonical)