From ebaeeb8112e513ee93cc5e0b47f5c2c3d7853e69 Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Fri, 2 May 2025 15:15:45 -0300 Subject: [PATCH] math: Fix UB on ldbl-96 remquol Building with --enable-ubasn triggers: $ math/test-ldouble-pow testing long double (without inline functions) UBSAN: Undefined behaviour in ../sysdeps/ieee754/ldbl-96/s_roundl.c:75:28 left shift of 1 by 31 cannot be represented in type 'int' --- sysdeps/ieee754/ldbl-96/s_remquol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysdeps/ieee754/ldbl-96/s_remquol.c b/sysdeps/ieee754/ldbl-96/s_remquol.c index 65a22bb5e4..27c6fbaa2d 100644 --- a/sysdeps/ieee754/ldbl-96/s_remquol.c +++ b/sysdeps/ieee754/ldbl-96/s_remquol.c @@ -50,7 +50,7 @@ __remquol (long double x, long double p, int *quo) if (ep <= 0x7ffb) x = __ieee754_fmodl (x, 8 * p); /* now x < 8p */ - if (((ex - ep) | (hx - hp) | (lx - lp)) == 0) + if ((ex == ep) && (hx == hp) && (lx == lp)) { *quo = qs ? -1 : 1; return zero * x; -- 2.47.2