Skip to content

Commit 7ba207a

Browse files
committed
[libc++][C++03] cherry-pick #106566
1 parent eaff28c commit 7ba207a

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

libcxx/include/__cxx03/__math/traits.h

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include <__cxx03/__config>
1313
#include <__cxx03/__type_traits/enable_if.h>
1414
#include <__cxx03/__type_traits/is_arithmetic.h>
15-
#include <__cxx03/__type_traits/is_floating_point.h>
1615
#include <__cxx03/__type_traits/is_integral.h>
1716
#include <__cxx03/__type_traits/is_signed.h>
1817
#include <__cxx03/__type_traits/promote.h>
@@ -28,8 +27,21 @@ namespace __math {
2827

2928
// signbit
3029

31-
template <class _A1, __enable_if_t<is_floating_point<_A1>::value, int> = 0>
32-
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT {
30+
// The universal C runtime (UCRT) in the WinSDK provides floating point overloads
31+
// for std::signbit(). By defining our overloads as templates, we can work around
32+
// this issue as templates are less preferred than non-template functions.
33+
template <class = void>
34+
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool signbit(float __x) _NOEXCEPT {
35+
return __builtin_signbit(__x);
36+
}
37+
38+
template <class = void>
39+
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool signbit(double __x) _NOEXCEPT {
40+
return __builtin_signbit(__x);
41+
}
42+
43+
template <class = void>
44+
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool signbit(long double __x) _NOEXCEPT {
3345
return __builtin_signbit(__x);
3446
}
3547

libcxx/test/std/numerics/c.math/signbit.pass.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
// GCC warns about signbit comparing `bool_v < 0`, which we're testing
1818
// ADDITIONAL_COMPILE_FLAGS(gcc): -Wno-bool-compare
1919

20-
// XFAIL: FROZEN-CXX03-HEADERS-FIXME
21-
2220
#include <cassert>
2321
#include <cmath>
2422
#include <limits>

0 commit comments

Comments
 (0)