From: Adhemerval Zanella Date: Tue, 22 Apr 2025 18:57:10 +0000 (-0300) Subject: math: Fix UB in test-canonical-ldbl-96.c X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8beaca2512f177a306d16d678760098c4aba7b89;p=thirdparty%2Fglibc.git math: Fix UB in test-canonical-ldbl-96.c 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' --- diff --git a/sysdeps/ieee754/ldbl-96/test-canonical-ldbl-96.c b/sysdeps/ieee754/ldbl-96/test-canonical-ldbl-96.c index 898bea9fd1..707e5fa7c4 100644 --- a/sysdeps/ieee754/ldbl-96/test-canonical-ldbl-96.c +++ b/sysdeps/ieee754/ldbl-96/test-canonical-ldbl-96.c @@ -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)