[libcxx-commits] [libcxx] [libc++] Fix shared_ptr(Y*) constraint check on GCC (PR #199429)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Sun May 24 08:29:20 PDT 2026
https://github.com/philnik777 created https://github.com/llvm/llvm-project/pull/199429
GCC has fixed SFINAEing on `delete` since at least GCC 11, so we can properly constrain the constructor.
>From 92405cda9c552317faae20c4464d36b295c40c50 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Sun, 24 May 2026 17:28:32 +0200
Subject: [PATCH] [libc++] Fix shared_ptr(Y*) constraint check on GCC
---
libcxx/include/__memory/shared_ptr.h | 2 +-
.../util.smartptr.shared.const/shared_ptr_Y.pass.cpp | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/libcxx/include/__memory/shared_ptr.h b/libcxx/include/__memory/shared_ptr.h
index bbf4a5553f78d..e621e89027d20 100644
--- a/libcxx/include/__memory/shared_ptr.h
+++ b/libcxx/include/__memory/shared_ptr.h
@@ -333,7 +333,7 @@ class _LIBCPP_SHARED_PTR_TRIVIAL_ABI shared_ptr {
// In C++03 we get errors when trying to do SFINAE with the
// delete operator, so we always pretend that it's deletable.
// The same happens on GCC.
-#if !defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_COMPILER_GCC)
+#if !defined(_LIBCPP_CXX03_LANG)
,
_If<is_array<_Tp>::value, __is_array_deletable<_Yp*>, __is_deletable<_Yp*> >
#endif
diff --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y.pass.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y.pass.cpp
index 06817302446e8..49756d29dcc61 100644
--- a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y.pass.cpp
+++ b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y.pass.cpp
@@ -137,7 +137,7 @@ int main(int, char**)
// This should work in C++03 but we get errors when trying to do SFINAE with the delete operator.
// GCC also complains about this.
-#if TEST_STD_VER >= 11 && !defined(TEST_COMPILER_GCC)
+#if TEST_STD_VER >= 11
{
// LWG2874: Make sure that when T (for std::shared_ptr<T>) is an array type,
// this constructor only participates in overload resolution when
More information about the libcxx-commits
mailing list