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

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


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

>From 84169133595eaef0a1516d9e407046b4baa10c3f Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Thu, 17 Sep 2026 10:14:04 +0200
Subject: [PATCH] [libc++] Remove workaround to make fpclassify constexpr for
 the UCRT

---
 libcxx/include/math.h                         | 29 -------------------
 .../std/numerics/c.math/fpclassify.pass.cpp   |  3 ++
 2 files changed, 3 insertions(+), 29 deletions(-)

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>



More information about the libcxx-commits mailing list