[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 22:49:20 PDT 2025
https://github.com/steffenlarsen created https://github.com/llvm/llvm-project/pull/150374
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.
>From fcccaa9259c07fa36b837e855a830638382f5539 Mon Sep 17 00:00:00 2001
From: Steffen Larsen <steffen.larsen at intel.com>
Date: Thu, 24 Jul 2025 07:35:49 +0200
Subject: [PATCH] [libc++] Fix return type of ilogb(double)
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.
---
libcxx/include/__cxx03/__math/logarithms.h | 2 +-
libcxx/include/__math/logarithms.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
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);
}
More information about the libcxx-commits
mailing list