[libcxx-commits] [libcxx] [libc++] Fix return type of ilogb(double) (PR #150374)
via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jul 23 22:49:51 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
Author: Steffen Larsen (steffenlarsen)
<details>
<summary>Changes</summary>
This commit addresses a seemingly unintentional return type of the ilogb overload taking a double. Currently it returns double, while it is supposed to return int.
The return types seems to be covered by
libcxx/test/std/numerics/c.math/cmath.pass.cpp, so it is unclear how this discrepancy has gone undetected.
---
Full diff: https://github.com/llvm/llvm-project/pull/150374.diff
2 Files Affected:
- (modified) libcxx/include/__cxx03/__math/logarithms.h (+1-1)
- (modified) libcxx/include/__math/logarithms.h (+1-1)
``````````diff
diff --git a/libcxx/include/__cxx03/__math/logarithms.h b/libcxx/include/__cxx03/__math/logarithms.h
index 25473501435cc..9b9e59a5a7baf 100644
--- a/libcxx/include/__cxx03/__math/logarithms.h
+++ b/libcxx/include/__cxx03/__math/logarithms.h
@@ -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 {
return __builtin_ilogb(__x);
}
diff --git a/libcxx/include/__math/logarithms.h b/libcxx/include/__math/logarithms.h
index 5f5f943977a50..7343d6a84ad4b 100644
--- a/libcxx/include/__math/logarithms.h
+++ b/libcxx/include/__math/logarithms.h
@@ -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 {
return __builtin_ilogb(__x);
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/150374
More information about the libcxx-commits
mailing list