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

via libcxx-commits libcxx-commits at lists.llvm.org
Wed Oct 14 00:26:44 PDT 2026


Author: Nikolas Klauser
Date: 2026-10-14T09:26:39+02:00
New Revision: 28c04e2013a38554fdf7008047857f628011cfb1

URL: https://github.com/llvm/llvm-project/commit/28c04e2013a38554fdf7008047857f628011cfb1
DIFF: https://github.com/llvm/llvm-project/commit/28c04e2013a38554fdf7008047857f628011cfb1.diff

LOG: [libc++] Remove workaround to make fpclassify constexpr for the UCRT (#224226)

We've decided that we don't want to work around the UCRT to allow
constant evaluation for the math functions for the time being. Remove
the one already landed workaround.

Added: 
    

Modified: 
    libcxx/include/math.h
    libcxx/test/std/numerics/c.math/fpclassify.pass.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/include/math.h b/libcxx/include/math.h
index 9d0642398b7d4..b6ee11f69f681 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 b5fa618655c3e..a78773d5b7556 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