From e858063070eedb7fe78c37eba5177d8c5cfccfa6 Mon Sep 17 00:00:00 2001 From: Szabolcs Nagy Date: Sun, 13 Oct 2019 14:54:31 +0000 Subject: math: fix signed int left shift ub in sqrt Both sqrt and sqrtf shifted the signed exponent as signed int to adjust the bit representation of the result. There are signed right shifts too in the code but those are implementation defined and are expected to compile to arithmetic shift on supported compilers and targets. --- src/math/sqrtf.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/math/sqrtf.c') diff --git a/src/math/sqrtf.c b/src/math/sqrtf.c index 28cb4ad3..d6ace38a 100644 --- a/src/math/sqrtf.c +++ b/src/math/sqrtf.c @@ -78,7 +78,6 @@ float sqrtf(float x) } } ix = (q>>1) + 0x3f000000; - ix += m << 23; - SET_FLOAT_WORD(z, ix); + SET_FLOAT_WORD(z, ix + ((uint32_t)m << 23)); return z; } -- cgit v1.2.1