Skip to content

Commit 81b20e1

Browse files
authored
[libc++] Work around new GCC 15 type_traits builtins that can't be used as Clang's can (#137871)
GCC 15 has added builtins for various C++ type traits that Clang already had. Since `__has_builtin(...)` now finds these, the #if branches previously only used for Clang are now used for GCC 15. However, GCC 15 requires that these builtins only be used in type aliases, not in template aliases. For now, just don't use the `__has_builtin(...)` branches under newer GCC versions, so both 14 and 15 work during the transition. This can be cleaned up later to use all the GCC 15 builtins available. Fixed: #137704 Fixed: #117319
1 parent 8193294 commit 81b20e1

File tree

6 files changed

+6
-6
lines changed

6 files changed

+6
-6
lines changed

libcxx/include/__type_traits/add_lvalue_reference.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
_LIBCPP_BEGIN_NAMESPACE_STD
2020

21-
#if __has_builtin(__add_lvalue_reference)
21+
#if __has_builtin(__add_lvalue_reference) && !defined(_LIBCPP_COMPILER_GCC)
2222

2323
template <class _Tp>
2424
using __add_lvalue_reference_t _LIBCPP_NODEBUG = __add_lvalue_reference(_Tp);

libcxx/include/__type_traits/add_pointer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
_LIBCPP_BEGIN_NAMESPACE_STD
2222

23-
#if !defined(_LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS) && __has_builtin(__add_pointer)
23+
#if !defined(_LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS) && __has_builtin(__add_pointer) && !defined(_LIBCPP_COMPILER_GCC)
2424

2525
template <class _Tp>
2626
using __add_pointer_t _LIBCPP_NODEBUG = __add_pointer(_Tp);

libcxx/include/__type_traits/add_rvalue_reference.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
_LIBCPP_BEGIN_NAMESPACE_STD
2020

21-
#if __has_builtin(__add_rvalue_reference)
21+
#if __has_builtin(__add_rvalue_reference) && !defined(_LIBCPP_COMPILER_GCC)
2222

2323
template <class _Tp>
2424
using __add_rvalue_reference_t _LIBCPP_NODEBUG = __add_rvalue_reference(_Tp);

libcxx/include/__type_traits/decay.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
_LIBCPP_BEGIN_NAMESPACE_STD
2727

28-
#if __has_builtin(__decay)
28+
#if __has_builtin(__decay) && !defined(_LIBCPP_COMPILER_GCC)
2929
template <class _Tp>
3030
using __decay_t _LIBCPP_NODEBUG = __decay(_Tp);
3131

libcxx/include/__type_traits/remove_all_extents.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
_LIBCPP_BEGIN_NAMESPACE_STD
2020

21-
#if __has_builtin(__remove_all_extents)
21+
#if __has_builtin(__remove_all_extents) && !defined(_LIBCPP_COMPILER_GCC)
2222
template <class _Tp>
2323
struct _LIBCPP_NO_SPECIALIZATIONS remove_all_extents {
2424
using type _LIBCPP_NODEBUG = __remove_all_extents(_Tp);

libcxx/include/__type_traits/remove_extent.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
_LIBCPP_BEGIN_NAMESPACE_STD
2020

21-
#if __has_builtin(__remove_extent)
21+
#if __has_builtin(__remove_extent) && !defined(_LIBCPP_COMPILER_GCC)
2222
template <class _Tp>
2323
struct _LIBCPP_NO_SPECIALIZATIONS remove_extent {
2424
using type _LIBCPP_NODEBUG = __remove_extent(_Tp);

0 commit comments

Comments
 (0)