From b3d1d1f4fff816423ea8c652d8d849aacc4c6ce8 Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Mon, 14 Dec 2020 16:58:52 -0500 Subject: [PATCH] [libc++] Remove unnecessary static assertion in allocate_shared Checking that `T` is constructible from `Args...` is technically not required by the Standard, although any implementation will obviously error out if that's not satisfied. However, this check is incompatible with using Allocator construction in the control block (upcoming change as part of implementing P0674), so I'm removing it now to reduce the upcoming diff as much as possible. Differential Revision: https://reviews.llvm.org/D93246 --- libcxx/include/memory | 2 -- .../allocate_shared.protected.verify.cpp | 34 ---------------------- .../make_shared.protected.verify.cpp | 31 -------------------- 3 files changed, 67 deletions(-) delete mode 100644 libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.protected.verify.cpp delete mode 100644 libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.protected.verify.cpp diff --git a/libcxx/include/memory b/libcxx/include/memory index c676cd01c..4167f01 100644 --- a/libcxx/include/memory +++ b/libcxx/include/memory @@ -3307,8 +3307,6 @@ template allocate_shared(const _Alloc& __a, _Args&& ...__args) { - static_assert(is_constructible<_Tp, _Args...>::value, - "allocate_shared/make_shared: the type is not constructible from the provided arguments"); using _ControlBlock = __shared_ptr_emplace<_Tp, _Alloc>; using _ControlBlockAllocator = typename __allocator_traits_rebind<_Alloc, _ControlBlock>::type; __allocation_guard<_ControlBlockAllocator> __guard(__a, 1); diff --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.protected.verify.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.protected.verify.cpp deleted file mode 100644 index fbd7bfa..0000000 --- a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.protected.verify.cpp +++ /dev/null @@ -1,34 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// GCC 5 does not evaluate static assertions dependent on a template parameter. -// UNSUPPORTED: gcc-5 - -// - -// shared_ptr - -// template -// shared_ptr allocate_shared(const A& a, Args&&... args); - -#include - -#include "test_macros.h" - -struct S { -protected: - S () {}; // ctor is protected -}; - -int main(int, char**) { - typedef std::allocator A; - A a; - std::shared_ptr p = std::allocate_shared(a); // expected-error@memory:* {{static_assert failed due to requirement 'is_constructible::value}} - - return 0; -} diff --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.protected.verify.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.protected.verify.cpp deleted file mode 100644 index a2b6e98..0000000 --- a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.protected.verify.cpp +++ /dev/null @@ -1,31 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// GCC 5 does not evaluate static assertions dependent on a template parameter. -// UNSUPPORTED: gcc-5 - -// - -// shared_ptr - -// template shared_ptr make_shared(Args&&... args); - -#include - -#include "test_macros.h" - -struct S { -protected: - S () {}; // ctor is protected -}; - -int main(int, char**) { - std::shared_ptr p = std::make_shared(); // expected-error@memory:* {{static_assert failed due to requirement 'is_constructible::value}} - - return 0; -} -- 2.7.4