[libcxx-commits] [libcxx] 7980fa0 - [libc++] Tweak comments for workaround about `fpclassify` overloads (#212388)

via libcxx-commits libcxx-commits at lists.llvm.org
Tue Aug 4 08:49:14 PDT 2026


Author: A. Jiang
Date: 2026-08-04T11:49:10-04:00
New Revision: 7980fa07f3c3633504c617e05b31673b50565957

URL: https://github.com/llvm/llvm-project/commit/7980fa07f3c3633504c617e05b31673b50565957
DIFF: https://github.com/llvm/llvm-project/commit/7980fa07f3c3633504c617e05b31673b50565957.diff

LOG: [libc++] Tweak comments for workaround about `fpclassify` overloads (#212388)

Explaining why we have `_LIBCPP_PREFERRED_OVERLOAD` and template
versions.

Added: 
    

Modified: 
    libcxx/include/math.h

Removed: 
    


################################################################################
diff  --git a/libcxx/include/math.h b/libcxx/include/math.h
index 0aed0db87270c..9d0642398b7d4 100644
--- a/libcxx/include/math.h
+++ b/libcxx/include/math.h
@@ -387,6 +387,12 @@ 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 {
@@ -409,8 +415,6 @@ fpclassify(_A1 __x) _NOEXCEPT {
   return __x == 0 ? FP_ZERO : FP_NORMAL;
 }
 #      else
-
-// template on non-double overloads to make them weaker than same overloads from MSVC runtime
 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);


        


More information about the libcxx-commits mailing list