[glibc/azanella/ubsan-undef] math: Fix UB in flt-32 nearbyint
Adhemerval Zanella
azanella@sourceware.org
Thu May 8 14:05:56 GMT 2025
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=0a933c9bf75088406677d72da03604669361e0d4
commit 0a933c9bf75088406677d72da03604669361e0d4
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Tue May 6 13:43:36 2025 +0000
math: Fix UB in flt-32 nearbyint
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'
Diff:
---
sysdeps/ieee754/flt-32/s_nearbyintf.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/sysdeps/ieee754/flt-32/s_nearbyintf.c b/sysdeps/ieee754/flt-32/s_nearbyintf.c
index 5dd0e8f8af..8ae80738fc 100644
--- a/sysdeps/ieee754/flt-32/s_nearbyintf.c
+++ b/sysdeps/ieee754/flt-32/s_nearbyintf.c
@@ -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;
More information about the Glibc-cvs
mailing list