Skip to content

Conversation

philnik777
Copy link
Contributor

No description provided.

@philnik777 philnik777 marked this pull request as ready for review September 28, 2025 07:20
@philnik777 philnik777 requested a review from a team as a code owner September 28, 2025 07:20
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Sep 28, 2025
@llvmbot
Copy link
Member

llvmbot commented Sep 28, 2025

@llvm/pr-subscribers-libcxx

Author: Nikolas Klauser (philnik777)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/160661.diff

1 Files Affected:

  • (modified) libcxx/include/limits (+9-21)
diff --git a/libcxx/include/limits b/libcxx/include/limits
index e8581cf9c321d..6a93b770f68b0 100644
--- a/libcxx/include/limits
+++ b/libcxx/include/limits
@@ -455,9 +455,9 @@ class numeric_limits : private __libcpp_numeric_limits<_Tp> {
 
 public:
   static inline _LIBCPP_CONSTEXPR const bool is_specialized = __base::is_specialized;
-  [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __base::min(); }
-  [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __base::max(); }
-  [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return __base::lowest(); }
+  using __base::lowest;
+  using __base::max;
+  using __base::min;
 
   static inline _LIBCPP_CONSTEXPR const int digits       = __base::digits;
   static inline _LIBCPP_CONSTEXPR const int digits10     = __base::digits10;
@@ -466,12 +466,8 @@ public:
   static inline _LIBCPP_CONSTEXPR const bool is_integer  = __base::is_integer;
   static inline _LIBCPP_CONSTEXPR const bool is_exact    = __base::is_exact;
   static inline _LIBCPP_CONSTEXPR const int radix        = __base::radix;
-  [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {
-    return __base::epsilon();
-  }
-  [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {
-    return __base::round_error();
-  }
+  using __base::epsilon;
+  using __base::round_error;
 
   static inline _LIBCPP_CONSTEXPR const int min_exponent   = __base::min_exponent;
   static inline _LIBCPP_CONSTEXPR const int min_exponent10 = __base::min_exponent10;
@@ -485,18 +481,10 @@ public:
   static inline _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm;
   static inline _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss;
   _LIBCPP_SUPPRESS_DEPRECATED_POP
-  [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {
-    return __base::infinity();
-  }
-  [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {
-    return __base::quiet_NaN();
-  }
-  [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {
-    return __base::signaling_NaN();
-  }
-  [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {
-    return __base::denorm_min();
-  }
+  using __base::denorm_min;
+  using __base::infinity;
+  using __base::quiet_NaN;
+  using __base::signaling_NaN;
 
   static inline _LIBCPP_CONSTEXPR const bool is_iec559  = __base::is_iec559;
   static inline _LIBCPP_CONSTEXPR const bool is_bounded = __base::is_bounded;

[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __base::min(); }
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __base::max(); }
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return __base::lowest(); }
using __base::lowest;
Copy link
Member

@ldionne ldionne Oct 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a huge fan of the change as-is, since we now have to go down into the implementation of base classes to figure out the exact API (attributes, etc.), whereas before the patch we can see that right away.

As discussed, I think there might be other alternatives (using compiler builtins) that would provide similar gains without complicating this interface.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants