[libcxx-commits] [libcxx] [libc++] Fix move-only types in std::make_shared (PR #205819)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Jun 25 06:51:47 PDT 2026
https://github.com/philnik777 created https://github.com/llvm/llvm-project/pull/205819
None
>From 3592a5499ba4bbe35edf341779f25b652405b759 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Thu, 25 Jun 2026 15:51:28 +0200
Subject: [PATCH] [libc++] Fix move-only types in std::make_shared
---
libcxx/include/__memory/shared_ptr.h | 2 +-
.../util.smartptr.shared.create/make_shared.pass.cpp | 6 ++++++
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/libcxx/include/__memory/shared_ptr.h b/libcxx/include/__memory/shared_ptr.h
index 8d12e395bb86c..95b472c470593 100644
--- a/libcxx/include/__memory/shared_ptr.h
+++ b/libcxx/include/__memory/shared_ptr.h
@@ -657,7 +657,7 @@ _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> __allocate_shared_impl(const _Alloc& __all
template <class _Tp, class _Alloc, class... _Args, __enable_if_t<!is_array<_Tp>::value, int> = 0>
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared(const _Alloc& __a, _Args&&... __args) {
using _ControlBlock = __shared_ptr_emplace<_Tp, __allocator_traits_rebind_t<_Alloc, __remove_cv_t<_Tp> > >;
- return std::__allocate_shared_impl<_ControlBlock, _Tp>(__a, __args...);
+ return std::__allocate_shared_impl<_ControlBlock, _Tp>(__a, std::forward<_Args>(__args)...);
}
template <class _Tp, class... _Args, __enable_if_t<!is_array<_Tp>::value, int> = 0>
diff --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp
index be7505f218cdd..a18be769d5cfd 100644
--- a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp
+++ b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp
@@ -19,6 +19,7 @@
#include "count_new.h"
#include "operator_hijacker.h"
#include "test_macros.h"
+#include "MoveOnly.h"
struct A
{
@@ -91,6 +92,11 @@ void test(const T &t0)
int main(int, char**)
{
+ {
+ auto val = std::make_shared<MoveOnly>(MoveOnly{});
+ assert(val->get() == 1);
+ }
+
int nc = globalMemCounter.outstanding_new;
{
int i = 67;
More information about the libcxx-commits
mailing list