[libcxx-commits] [libcxx] [libc++] Fix return type of ilogb(double) (PR #150374)

Steffen Larsen via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jul 23 23:29:15 PDT 2025


================
@@ -58,7 +58,7 @@ inline _LIBCPP_HIDE_FROM_ABI double log10(_A1 __x) _NOEXCEPT {
 inline _LIBCPP_HIDE_FROM_ABI int ilogb(float __x) _NOEXCEPT { return __builtin_ilogbf(__x); }
 
 template <class = int>
-_LIBCPP_HIDE_FROM_ABI double ilogb(double __x) _NOEXCEPT {
+_LIBCPP_HIDE_FROM_ABI int ilogb(double __x) _NOEXCEPT {
----------------
steffenlarsen wrote:

> IIUC on every platform where libc++ is supported, `ilogb(0.0)`/`std::ilogb(0.0)` selects the `ilogb` function provided by the underlying C standard library. I wonder whether we can just remove this overload (and many overloads for `double` in `<cmath>`).

I suppose this may be the reason for the templating. If there is non-templated `ilogb(double)`, that would take priority over this, which may explain why the cmath.pass.cpp test typically doesn't fail. However, could this still be useful in cases where libc isn't found? Can that happen?

https://github.com/llvm/llvm-project/pull/150374


More information about the libcxx-commits mailing list