[libcxx-commits] [libcxx] [libc++][math] Add `constexpr` to `copysign` functions (PR #216285)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Tue Aug 18 02:34:02 PDT 2026


================
@@ -424,8 +424,15 @@ using ::atanhf _LIBCPP_USING_IF_EXISTS;
 using ::cbrt _LIBCPP_USING_IF_EXISTS;
 using ::cbrtf _LIBCPP_USING_IF_EXISTS;
 
-using ::copysign _LIBCPP_USING_IF_EXISTS;
+using std::__math::copysign;
+
+#  if _LIBCPP_STD_VER >= 23 && __has_constexpr_builtin(__builtin_copysignf)
+_LIBCPP_HIDE_FROM_ABI constexpr float copysignf(float __x, float __y) _NOEXCEPT {
+  return __builtin_copysignf(__x, __y);
+}
+#  else
----------------
philnik777 wrote:

This is non-conforming.
```
using namespace std;

auto test() {
  return std::copysignf(1.f, 1.f);
}
```
fails due to the ambiguous overload.

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


More information about the libcxx-commits mailing list