From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 2FFC239B90BA; Thu, 19 Aug 2021 12:03:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2FFC239B90BA MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r12-3022] libstdc++: Fix move construction of std::tuple with array elements [PR101960] X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: 926d4a71c7e5a2f7d17a4f943d6e7fe9f1e3ba55 X-Git-Newrev: 0187e0d7360f327f88d8b2294668669306ae4630 Message-Id: <20210819120308.2FFC239B90BA@sourceware.org> Date: Thu, 19 Aug 2021 12:03:08 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Aug 2021 12:03:08 -0000 https://gcc.gnu.org/g:0187e0d7360f327f88d8b2294668669306ae4630 commit r12-3022-g0187e0d7360f327f88d8b2294668669306ae4630 Author: Jonathan Wakely Date: Thu Aug 19 11:48:40 2021 +0100 libstdc++: Fix move construction of std::tuple with array elements [PR101960] An array member cannot be direct-initialized in a ctor-initializer-list, so use the base class' move constructor, which does the right thing for both arrays and non-arrays. This constructor could be defaulted, but that would make it trivial for some specializations, which would change the argument passing ABI. Do that for the versioned namespace only. Signed-off-by: Jonathan Wakely libstdc++-v3/ChangeLog: PR libstdc++/101960 * include/std/tuple (_Tuple_impl(_Tuple_impl&&)): Use base class' move constructor. Define as defaulted for versioned namespace. * testsuite/20_util/tuple/cons/101960.cc: New test. Diff: --- libstdc++-v3/include/std/tuple | 6 +++++- libstdc++-v3/testsuite/20_util/tuple/cons/101960.cc | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple index 1292aee45c0..f082ccb8a3b 100644 --- a/libstdc++-v3/include/std/tuple +++ b/libstdc++-v3/include/std/tuple @@ -438,11 +438,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // 2729. Missing SFINAE on std::pair::operator= _Tuple_impl& operator=(const _Tuple_impl&) = delete; +#if _GLIBCXX_INLINE_VERSION + _Tuple_impl(_Tuple_impl&&) = default; +#else constexpr _Tuple_impl(_Tuple_impl&& __in) noexcept(is_nothrow_move_constructible<_Head>::value) - : _Base(std::forward<_Head>(_M_head(__in))) + : _Base(static_cast<_Base&&>(__in)) { } +#endif template constexpr diff --git a/libstdc++-v3/testsuite/20_util/tuple/cons/101960.cc b/libstdc++-v3/testsuite/20_util/tuple/cons/101960.cc new file mode 100644 index 00000000000..f14604cdc69 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/cons/101960.cc @@ -0,0 +1,4 @@ +// { dg-do compile { target c++11 } } +#include +std::tuple t; +auto tt = std::move(t); // PR libstdc++/101960