musl - musl - an implementation of the standard library for Linux-based systems

index : musl
musl - an implementation of the standard library for Linux-based systems
summary refs log tree commit diff
path: root/src/math/sqrt.c
diff options
context:
space:
mode:
authorSzabolcs Nagy <nsz@port70.net>2019年10月13日 14:54:31 +0000
committerRich Felker <dalias@aerifal.cx>2019年10月13日 17:46:58 -0400
commite858063070eedb7fe78c37eba5177d8c5cfccfa6 (patch)
tree096107b70bf29ed69cdb761894a91c230b885fa7 /src/math/sqrt.c
parent716745e00e304a650a8eef57c15fbd326168096e (diff)
downloadmusl-e858063070eedb7fe78c37eba5177d8c5cfccfa6.tar.gz
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.
Diffstat (limited to 'src/math/sqrt.c')
-rw-r--r--src/math/sqrt.c 3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/math/sqrt.c b/src/math/sqrt.c
index b2775673..f1f6d76c 100644
--- a/src/math/sqrt.c
+++ b/src/math/sqrt.c
@@ -179,7 +179,6 @@ double sqrt(double x)
ix1 = q1>>1;
if (q&1)
ix1 |= sign;
- ix0 += m << 20;
- INSERT_WORDS(z, ix0, ix1);
+ INSERT_WORDS(z, ix0 + ((uint32_t)m << 20), ix1);
return z;
}
generated by cgit v1.2.1 (git 2.18.0) at 2025年10月05日 03:12:43 +0000

AltStyle によって変換されたページ (->オリジナル) /