]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
math: Fix UB in flt-32 rint
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 6 May 2025 13:46:34 +0000 (13:46 +0000)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Thu, 8 May 2025 12:25:49 +0000 (09:25 -0300)
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'

sysdeps/ieee754/flt-32/s_rintf.c

index fe5258ae61d78c33feeb8ac32b55b0ea3084fbf7..9e37c52411073b43e24e3a834a6b957f5440b7fa 100644 (file)
@@ -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;