diff mbox series

[1/8] math: Fix UB on atanhf

Message ID 20250425205618.360232-2-adhemerval.zanella@linaro.org
State New
Headers show
Series Fix UB in math implementations | expand

Commit Message

Adhemerval Zanella April 25, 2025, 8:54 p.m. UTC
The left shift overflows for 'int', use unsigned instead.  It syncs
with CORE-MATH commit 4d6192d2.

Checked on aarch64-linux-gnu, x86_64-linux-gnu, and i686-linux-gnu.
---
 sysdeps/ieee754/flt-32/e_atanhf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/sysdeps/ieee754/flt-32/e_atanhf.c b/sysdeps/ieee754/flt-32/e_atanhf.c
index 5138408324..eeb1aae6a1 100644
--- a/sysdeps/ieee754/flt-32/e_atanhf.c
+++ b/sysdeps/ieee754/flt-32/e_atanhf.c
@@ -3,7 +3,7 @@ 
 Copyright (c) 2023-2024 Alexei Sibidanov.
 
 The original version of this file was copied from the CORE-MATH
-project (file src/binary32/acosh/acoshf.c, revision bc385c2).
+project (file src/binary32/acosh/acoshf.c, revision 4d6192d2).
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
@@ -135,7 +135,7 @@  __ieee754_atanhf (float x)
     }
   double sgn = s[ux >> 31];
   unsigned int e = ax >> 24;
-  unsigned int md = ((ux << 8) | 1 << 31) >> (126 - e);
+  unsigned int md = ((ux << 8) | 1U << 31) >> (126 - e);
   unsigned int mn = -md;
   int nz = __builtin_clz (mn) + 1;
   mn <<= nz;