]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
math: Fix UB in flt-32 nearbyint
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 6 May 2025 13:43:36 +0000 (13:43 +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_nearbyintf.c:53:4 left shift of 1 by 31 cannot be represented in type 'int'

sysdeps/ieee754/flt-32/s_nearbyintf.c

index 5dd0e8f8af8431ad0f0f8966ce8ded5a1e5f4044..8ae80738fc17c77468a8f0b2efda5fa1143f5744 100644 (file)
@@ -34,7 +34,8 @@ __nearbyintf (float x)
                -8.3886080000e+06, /* 0xcb000000 */
   };
   fenv_t env;
-  int32_t i0, j0, sx;
+  int32_t i0, j0;
+  uint32_t sx;
   float w, t;
   GET_FLOAT_WORD (i0, x);
   sx = (i0 >> 31) & 1;