[libcxx-commits] [libcxx] [libc++] Remove workaround to make fpclassify constexpr for the UCRT (PR #224226)

via libcxx-commits libcxx-commits at lists.llvm.org
Tue Oct 13 05:46:19 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libcxx

Author: Nikolas Klauser (philnik777)

<details>
<summary>Changes</summary>



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


2 Files Affected:

- (modified) libcxx/include/math.h (-29) 
- (modified) libcxx/test/std/numerics/c.math/fpclassify.pass.cpp (+3) 


``````````diff
diff --git a/libcxx/include/math.h b/libcxx/include/math.h
index 9d0642398b7d45..b6ee11f69f6811 100644
--- a/libcxx/include/math.h
+++ b/libcxx/include/math.h
@@ -387,34 +387,6 @@ namespace __math {
 
 // fpclassify
 
-// MS UCRT provides non-template fpclassify overloads for float, double, and long double that are unconditionally
-// non-constexpr.
-// To workaround this, we use _LIBCPP_PREFERRED_OVERLOAD to make our overloads stronger than those overloads, which is
-// necessary for constexpr addition in C++23. When _LIBCPP_PREFERRED_OVERLOAD is not supported, we use template
-// overloads as a workaround to avoid conflicts.
-
-#      ifdef _LIBCPP_PREFERRED_OVERLOAD
-[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD int fpclassify(float __x) _NOEXCEPT {
-  return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
-}
-
-[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD int
-fpclassify(double __x) _NOEXCEPT {
-  return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
-}
-
-[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD int
-fpclassify(long double __x) _NOEXCEPT {
-  return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
-}
-
-template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value, int> = 0>
-[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD int
-fpclassify(_A1 __x) _NOEXCEPT {
-  return __x == 0 ? FP_ZERO : FP_NORMAL;
-}
-#      else
 template <class = int>
 [[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int fpclassify(float __x) _NOEXCEPT {
   return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
@@ -434,7 +406,6 @@ template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value, int> = 0>
 [[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int fpclassify(_A1 __x) _NOEXCEPT {
   return __x == 0 ? FP_ZERO : FP_NORMAL;
 }
-#      endif
 
 } // namespace __math
 
diff --git a/libcxx/test/std/numerics/c.math/fpclassify.pass.cpp b/libcxx/test/std/numerics/c.math/fpclassify.pass.cpp
index b5fa618655c3ef..a78773d5b7556a 100644
--- a/libcxx/test/std/numerics/c.math/fpclassify.pass.cpp
+++ b/libcxx/test/std/numerics/c.math/fpclassify.pass.cpp
@@ -8,6 +8,9 @@
 
 // bool fpclassify(floating-point-type x); // constexpr since C++23
 
+// We don't control the implementation on windows
+// UNSUPPORTED: windows
+
 #include <cassert>
 #include <cmath>
 #include <limits>

``````````

</details>


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


More information about the libcxx-commits mailing list