]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Fix up std::{,b}float16_t std::{ilogb,l{,l}r{ound,int}} [PR117406]
authorJakub Jelinek <jakub@redhat.com>
Sat, 2 Nov 2024 17:48:54 +0000 (18:48 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Sat, 2 Nov 2024 17:48:54 +0000 (18:48 +0100)
commit36a9e2b22596711455e702ea5a5a3f26e145321c
tree135209a5889ac997801d36bc340bf5dbe7dbb50d
parent1fb467dbcc2cdd3bb89fa860a1f86b7e334e0ce3
libstdc++: Fix up std::{,b}float16_t std::{ilogb,l{,l}r{ound,int}} [PR117406]

These overloads incorrectly cast the result of the float __builtin_*
to _Float or __gnu_cxx::__bfloat16_t.  For std::ilogb that changes
behavior for the INT_MAX return because that isn't representable in
either of the floating point formats, for the others it is I think
just a very inefficient hop from int/long/long long to std::{,b}float16_t
and back.  I mean for the round/rint cases, either the argument is small
and then the return value should be representable in the floating point
format too, or it is too large that the argument is already integral
and then it should just return the argument with the round trips.
Too large value is unspecified unlike ilogb.

2024-11-02  Jakub Jelinek  <jakub@redhat.com>

PR libstdc++/117406
* include/c_global/cmath (std::ilogb(_Float16), std::llrint(_Float16),
std::llround(_Float16), std::lrint(_Float16), std::lround(_Float16)):
Don't cast __builtin_* return to _Float16.
(std::ilogb(__gnu_cxx::__bfloat16_t),
std::llrint(__gnu_cxx::__bfloat16_t),
std::llround(__gnu_cxx::__bfloat16_t),
std::lrint(__gnu_cxx::__bfloat16_t),
std::lround(__gnu_cxx::__bfloat16_t)): Don't cast __builtin_* return to
__gnu_cxx::__bfloat16_t.
* testsuite/26_numerics/headers/cmath/117406.cc: New test.
libstdc++-v3/include/c_global/cmath
libstdc++-v3/testsuite/26_numerics/headers/cmath/117406.cc [new file with mode: 0644]