From: Adhemerval Zanella Date: Tue, 6 May 2025 13:46:34 +0000 (+0000) Subject: math: Fix UB in flt-32 rint X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=98b2b7be53096944a8f99cf1da7761ae6c60d077;p=thirdparty%2Fglibc.git math: Fix UB in flt-32 rint UBSAN: Undefined behaviour in ../sysdeps/ieee754/flt-32/s_rintf.c:46:4 left shift of 1 by 31 cannot be represented in type 'int' --- diff --git a/sysdeps/ieee754/flt-32/s_rintf.c b/sysdeps/ieee754/flt-32/s_rintf.c index fe5258ae61..9e37c52411 100644 --- a/sysdeps/ieee754/flt-32/s_rintf.c +++ b/sysdeps/ieee754/flt-32/s_rintf.c @@ -30,7 +30,8 @@ __rintf (float x) 8.3886080000e+06, /* 0x4b000000 */ -8.3886080000e+06, /* 0xcb000000 */ }; - int32_t i0, j0, sx; + int32_t i0, j0; + uint32_t sx; float w, t; GET_FLOAT_WORD (i0, x); sx = (i0 >> 31) & 1;