[libcxx-commits] [libcxx] [libc++] Only use remove_pointer builtin for Clang (PR #91838)

via libcxx-commits libcxx-commits at lists.llvm.org
Sun May 12 18:28:02 PDT 2024


https://github.com/Chilledheart updated https://github.com/llvm/llvm-project/pull/91838

>From 4cfd2df48458586f9ac886a09a2b6d504d7debe9 Mon Sep 17 00:00:00 2001
From: Keeyou <keeyou-cn at outlook.com>
Date: Sat, 11 May 2024 12:10:03 +0800
Subject: [PATCH] [libc++] Use remove_pointer builtin only for clang in traits
 impl.

For reference, gcc's remove_pointer builtin is added in 14.1 release
but the implementation is incomplete.

see https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/include/std/type_traits#L2105
and https://github.com/gcc-mirror/gcc/commit/40dd7a5fe5d.
---
 libcxx/include/__type_traits/remove_pointer.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libcxx/include/__type_traits/remove_pointer.h b/libcxx/include/__type_traits/remove_pointer.h
index 54390a1939f7d..2801cb9af1af6 100644
--- a/libcxx/include/__type_traits/remove_pointer.h
+++ b/libcxx/include/__type_traits/remove_pointer.h
@@ -17,7 +17,8 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#if !defined(_LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS) && __has_builtin(__remove_pointer)
+#if !defined(_LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS) && __has_builtin(__remove_pointer) &&                      \
+    defined(_LIBCPP_COMPILER_CLANG_BASED)
 template <class _Tp>
 struct remove_pointer {
   using type _LIBCPP_NODEBUG = __remove_pointer(_Tp);



More information about the libcxx-commits mailing list