[libcxx-commits] [libcxx] [libc++] Fix shared_ptr(Y*) constraint check on GCC (PR #199429)
via libcxx-commits
libcxx-commits at lists.llvm.org
Sun May 24 22:10:53 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
Author: Nikolas Klauser (philnik777)
<details>
<summary>Changes</summary>
GCC has fixed SFINAEing on `delete` since at least GCC 11, so we can properly constrain the constructor.
---
Full diff: https://github.com/llvm/llvm-project/pull/199429.diff
2 Files Affected:
- (modified) libcxx/include/__memory/shared_ptr.h (+1-1)
- (modified) libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y.pass.cpp (+1-1)
``````````diff
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
``````````
</details>
https://github.com/llvm/llvm-project/pull/199429
More information about the libcxx-commits
mailing list