[glibc/azanella/ubsan-undef] math: Fix UB in float128 atan2
Adhemerval Zanella
azanella@sourceware.org
Fri Apr 25 20:52:19 GMT 2025
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=8a45f66e63439cf94d7d5e300600f83fc15a3325
commit 8a45f66e63439cf94d7d5e300600f83fc15a3325
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Tue Apr 22 15:59:02 2025 -0300
math: Fix UB in float128 atan2
UBSAN: Undefined behaviour in ../sysdeps/ieee754/float128/../ldbl-128/e_atan2l.c:68:9 unsigned integer overflow: 9223372036854775808 - 4611404543450677248 cannot be represened in type 'long int'
Diff:
---
sysdeps/ieee754/ldbl-128/e_atan2l.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sysdeps/ieee754/ldbl-128/e_atan2l.c b/sysdeps/ieee754/ldbl-128/e_atan2l.c
index cdf08170f6..d2701084de 100644
--- a/sysdeps/ieee754/ldbl-128/e_atan2l.c
+++ b/sysdeps/ieee754/ldbl-128/e_atan2l.c
@@ -65,7 +65,7 @@ __ieee754_atan2l(_Float128 y, _Float128 x)
if(((ix|((lx|-lx)>>63))>0x7fff000000000000LL)||
((iy|((ly|-ly)>>63))>0x7fff000000000000LL)) /* x or y is NaN */
return x+y;
- if(((hx-0x3fff000000000000LL)|lx)==0) return __atanl(y); /* x=1.0L */
+ if((((uint64_t)hx-0x3fff000000000000LL)|lx)==0) return __atanl(y); /* x=1.0L */
m = ((hy>>63)&1)|((hx>>62)&2); /* 2*sign(x)+sign(y) */
/* when y = 0 */
More information about the Glibc-cvs
mailing list