[libcxx-commits] [libcxx] d06febc - [libc++] Fix shared_ptr(Y*) constraint check on GCC (#199429)

via libcxx-commits libcxx-commits at lists.llvm.org
Sun May 24 22:10:20 PDT 2026


Author: Nikolas Klauser
Date: 2026-05-25T07:10:15+02:00
New Revision: d06febc3a5fef5d87200a8af76c1efe811ba4dc0

URL: https://github.com/llvm/llvm-project/commit/d06febc3a5fef5d87200a8af76c1efe811ba4dc0
DIFF: https://github.com/llvm/llvm-project/commit/d06febc3a5fef5d87200a8af76c1efe811ba4dc0.diff

LOG: [libc++] Fix shared_ptr(Y*) constraint check on GCC (#199429)

GCC has fixed SFINAEing on `delete` since at least GCC 11, so we can
properly constrain the constructor.

Added: 
    

Modified: 
    libcxx/include/__memory/shared_ptr.h
    libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y.pass.cpp

Removed: 
    


################################################################################
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