https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117406
--- Comment #8 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-14 branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:377f81a60ba78dde6c59bc40af46ef8ad3569693 commit r14-10873-g377f81a60ba78dde6c59bc40af46ef8ad3569693 Author: Jakub Jelinek <ja...@redhat.com> Date: Sat Nov 2 18:48:54 2024 +0100 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 <ja...@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. (cherry picked from commit 36a9e2b22596711455e702ea5a5a3f26e145321c)