aboutsummaryrefslogtreecommitdiff
path: root/libobjc
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2023-08-07 15:30:03 +0100
committerJonathan Wakely <jwakely@redhat.com>2023-08-07 22:09:11 +0100
commitbb3ceeb6520c13fc5ca08af7d43fbd3f975e72b0 (patch)
treeb93076b023c654d1ae16c9bb033519e29f38fbdb /libobjc
parentc5ea5aecac323e9094e4dc967f54090cb244bc6a (diff)
downloadgcc-bb3ceeb6520c13fc5ca08af7d43fbd3f975e72b0.zip
gcc-bb3ceeb6520c13fc5ca08af7d43fbd3f975e72b0.tar.gz
gcc-bb3ceeb6520c13fc5ca08af7d43fbd3f975e72b0.tar.bz2
libstdc++: Fix incorrect use of abs and log10 in std::format [PR110860]
The std::formatter implementation for floating-point types uses __builtin_abs and __builtin_log10 to avoid including all of <cmath>, but those functions are not generic. The result of abs(2e304) is -INT_MIN which is undefined, and then log10(INT_MIN) is NaN. As well as being undefined, we fail to grow the buffer correctly, and then loop more times than needed to allocate a buffer and try formatting the value into it again. We can use if-constexpr to choose the correct form of log10 to use for the type, and avoid using abs entirely. This avoids the undefined behaviour and should mean we only reallocate and retry std::to_chars once. libstdc++-v3/ChangeLog: PR libstdc++/110860 * include/std/format (__formatter_fp::format): Do not use __builtin_abs and __builtin_log10 with arbitrary floating-point types.
Diffstat (limited to 'libobjc')
0 files changed, 0 insertions, 0 deletions