From: Adhemerval Zanella Date: Wed, 23 Apr 2025 19:20:28 +0000 (-0300) Subject: string: Fix UB on tesf-ffs X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e4b9aa70a7e133f89a635a314b3e5ee461912cd3;p=thirdparty%2Fglibc.git string: Fix UB on tesf-ffs UBSAN: Undefined behaviour in test-ffs.c:48:3 left shift of 1 by 31 cannot be represented in type 'int' --- diff --git a/string/test-ffs.c b/string/test-ffs.c index 3493cca421..db4f64f96e 100644 --- a/string/test-ffs.c +++ b/string/test-ffs.c @@ -40,9 +40,10 @@ do_test (void) #define TEST(fct, type) \ try (#fct, 0, fct ((type) 0), 0); \ for (i=0 ; i < 8 * sizeof (type); i++) \ - try (#fct, 1ll << i, fct (((type) 1) << i), i + 1); \ + try (#fct, 1ull << i, fct (((unsigned type) 1) << i), i + 1); \ for (i=0 ; i < 8 * sizeof (type) ; i++) \ - try (#fct, (~((type) 0) >> i) << i, fct ((~((type) 0) >> i) << i), i + 1);\ + try (#fct, (~((unsigned type) 0) >> i) << i, \ + fct ((~((unsigned type) 0) >> i) << i), i + 1);\ try (#fct, 0x80008000, fct ((type) 0x80008000), 16) TEST (ffs, int);