mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-22 20:01:08 +01:00
e75a1bbc23
A compiler clever enough to know that z is positive with a non-zero biased exponent could, for example, optimize away the scalbnf(z,n) in pow() because behavior for left shift of negative values is undefined. `n` is negative when y*log2(|x|) < -0.5. i.e. |x^y| < sqrt(0.5) The intended behavior for operator<< in this code is to shift the two's complement representation of the first operand. In the pow() functions, the result is added to the IEEE 754 exponent of z = 2^y'. n may be negative enough to underflow the biased IEEE 754 exponent below zero, which is manifested in the sign bit of j (which would correspond to the IEEE 754 sign bit). The conversion from uint32_t to int32_t for out-of-int32_t-range values is implementation defined. The assumed behavior of interpreting the uint32_t value as a two's complement representation of a signed value is already assumed in many parts of the code, such as uses of GET_FLOAT_WORD() with signed integers. This code passes all the current tests, and makes some out of tree fuzzing tests pass again rather than hit UB (detailed in the commentary of the pull request). Signed-off-by: Karl Tomlinson <karlt+@karlt.net> Reviewed by: imp, steve kargl, dim Pull Request: https://github.com/freebsd/freebsd-src/pull/1137 |
||
---|---|---|
.. | ||
aarch64 | ||
amd64 | ||
arm | ||
bsdsrc | ||
i387 | ||
ld80 | ||
ld128 | ||
man | ||
powerpc | ||
riscv | ||
src | ||
tests | ||
x86 | ||
Makefile | ||
Makefile.depend | ||
Symbol.map |