[libcxx-commits] [libcxx] [libc++] Fix return type of ilogb(double) (PR #150374)
A. Jiang via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jul 23 23:19:34 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 {
----------------
frederick-vs-ja wrote:
Per the related test file, it seems that this overload is never selected.
https://github.com/llvm/llvm-project/blob/75e60e745b029a3aaa199e8848e5542fd8a80395/libcxx/test/std/numerics/c.math/cmath.pass.cpp#L1234
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>`).
Also, `__math::ilogb` is not used within libc++, although some other functions in `__math` are used internally. So this overload is not used at all. I'm not sure whether we should fix the return type or remove this overload (together with some other templated function overloads for `double).
https://github.com/llvm/llvm-project/pull/150374
More information about the libcxx-commits
mailing list