[libcxx-commits] [libcxx] 81b20e1 - [libc++] Work around new GCC 15 type_traits builtins that can't be used as Clang's can (#137871)
via libcxx-commits
libcxx-commits at lists.llvm.org
Tue May 13 12:23:53 PDT 2025
Author: Roland McGrath
Date: 2025-05-13T12:23:50-07:00
New Revision: 81b20e110b3ffeb6d7069e7fe3e6339e63f8c03d
URL: https://github.com/llvm/llvm-project/commit/81b20e110b3ffeb6d7069e7fe3e6339e63f8c03d
DIFF: https://github.com/llvm/llvm-project/commit/81b20e110b3ffeb6d7069e7fe3e6339e63f8c03d.diff
LOG: [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
Added:
Modified:
libcxx/include/__type_traits/add_lvalue_reference.h
libcxx/include/__type_traits/add_pointer.h
libcxx/include/__type_traits/add_rvalue_reference.h
libcxx/include/__type_traits/decay.h
libcxx/include/__type_traits/remove_all_extents.h
libcxx/include/__type_traits/remove_extent.h
Removed:
################################################################################
diff --git a/libcxx/include/__type_traits/add_lvalue_reference.h b/libcxx/include/__type_traits/add_lvalue_reference.h
index 5e65477058e5f..42f91623f980c 100644
--- a/libcxx/include/__type_traits/add_lvalue_reference.h
+++ b/libcxx/include/__type_traits/add_lvalue_reference.h
@@ -18,7 +18,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if __has_builtin(__add_lvalue_reference)
+#if __has_builtin(__add_lvalue_reference) && !defined(_LIBCPP_COMPILER_GCC)
template <class _Tp>
using __add_lvalue_reference_t _LIBCPP_NODEBUG = __add_lvalue_reference(_Tp);
diff --git a/libcxx/include/__type_traits/add_pointer.h b/libcxx/include/__type_traits/add_pointer.h
index a9a51b86abaf0..f37f9cf5a93c0 100644
--- a/libcxx/include/__type_traits/add_pointer.h
+++ b/libcxx/include/__type_traits/add_pointer.h
@@ -20,7 +20,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if !defined(_LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS) && __has_builtin(__add_pointer)
+#if !defined(_LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS) && __has_builtin(__add_pointer) && !defined(_LIBCPP_COMPILER_GCC)
template <class _Tp>
using __add_pointer_t _LIBCPP_NODEBUG = __add_pointer(_Tp);
diff --git a/libcxx/include/__type_traits/add_rvalue_reference.h b/libcxx/include/__type_traits/add_rvalue_reference.h
index c51dd54a76789..33cc00180cc13 100644
--- a/libcxx/include/__type_traits/add_rvalue_reference.h
+++ b/libcxx/include/__type_traits/add_rvalue_reference.h
@@ -18,7 +18,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if __has_builtin(__add_rvalue_reference)
+#if __has_builtin(__add_rvalue_reference) && !defined(_LIBCPP_COMPILER_GCC)
template <class _Tp>
using __add_rvalue_reference_t _LIBCPP_NODEBUG = __add_rvalue_reference(_Tp);
diff --git a/libcxx/include/__type_traits/decay.h b/libcxx/include/__type_traits/decay.h
index 2e3d05d1e4871..1e663fdcd0eda 100644
--- a/libcxx/include/__type_traits/decay.h
+++ b/libcxx/include/__type_traits/decay.h
@@ -25,7 +25,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if __has_builtin(__decay)
+#if __has_builtin(__decay) && !defined(_LIBCPP_COMPILER_GCC)
template <class _Tp>
using __decay_t _LIBCPP_NODEBUG = __decay(_Tp);
diff --git a/libcxx/include/__type_traits/remove_all_extents.h b/libcxx/include/__type_traits/remove_all_extents.h
index bd7e8060f1a55..2c7aea2bfd182 100644
--- a/libcxx/include/__type_traits/remove_all_extents.h
+++ b/libcxx/include/__type_traits/remove_all_extents.h
@@ -18,7 +18,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if __has_builtin(__remove_all_extents)
+#if __has_builtin(__remove_all_extents) && !defined(_LIBCPP_COMPILER_GCC)
template <class _Tp>
struct _LIBCPP_NO_SPECIALIZATIONS remove_all_extents {
using type _LIBCPP_NODEBUG = __remove_all_extents(_Tp);
diff --git a/libcxx/include/__type_traits/remove_extent.h b/libcxx/include/__type_traits/remove_extent.h
index 75bb70015b79c..7745af14bdb17 100644
--- a/libcxx/include/__type_traits/remove_extent.h
+++ b/libcxx/include/__type_traits/remove_extent.h
@@ -18,7 +18,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if __has_builtin(__remove_extent)
+#if __has_builtin(__remove_extent) && !defined(_LIBCPP_COMPILER_GCC)
template <class _Tp>
struct _LIBCPP_NO_SPECIALIZATIONS remove_extent {
using type _LIBCPP_NODEBUG = __remove_extent(_Tp);
More information about the libcxx-commits
mailing list