From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id B56063857401 for ; Tue, 12 Oct 2021 15:50:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B56063857401 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-210-6MZBKMp7O2qzO6tlfEuWeg-1; Tue, 12 Oct 2021 11:50:20 -0400 X-MC-Unique: 6MZBKMp7O2qzO6tlfEuWeg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 351AC112958A; Tue, 12 Oct 2021 15:50:19 +0000 (UTC) Received: from localhost (unknown [10.33.37.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id B809D196F8; Tue, 12 Oct 2021 15:50:18 +0000 (UTC) Date: Tue, 12 Oct 2021 16:50:17 +0100 From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Fix move construction of std::tuple with array elements [PR101960] Message-ID: MIME-Version: 1.0 X-Clacks-Overhead: GNU Terry Pratchett X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/mixed; boundary="1FrMQ6VD5ln1lawX" Content-Disposition: inline X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP, URI_HEX autolearn=unavailable autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Oct 2021 15:50:24 -0000 --1FrMQ6VD5ln1lawX Content-Type: text/plain; charset=us-ascii Content-Disposition: inline The r12-3022 commit only fixed the case where an array is the last element of the tuple. This fixes the other cases too. We can just define the move constructor as defaulted, which does the right thing. Changing the move constructor to be trivial would be an ABI break, but since the last base class still has a non-trivial move constructor, defining the derived ones as defaulted doesn't change anything. libstdc++-v3/ChangeLog: PR libstdc++/101960 * include/std/tuple (_Tuple_impl(_Tuple_impl&&)): Define as defauled. * testsuite/20_util/tuple/cons/101960.cc: Check tuples with array elements before the last element. Tested powerpc64le-linux. Committed to trunk. --1FrMQ6VD5ln1lawX Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="patch.txt" commit 7481021364e75ba583972e15ed421a53988368ea Author: Jonathan Wakely Date: Tue Oct 12 15:09:50 2021 libstdc++: Fix move construction of std::tuple with array elements [PR101960] The r12-3022 commit only fixed the case where an array is the last element of the tuple. This fixes the other cases too. We can just define the move constructor as defaulted, which does the right thing. Changing the move constructor to be trivial would be an ABI break, but since the last base class still has a non-trivial move constructor, defining the derived ones as defaulted doesn't change anything. libstdc++-v3/ChangeLog: PR libstdc++/101960 * include/std/tuple (_Tuple_impl(_Tuple_impl&&)): Define as defauled. * testsuite/20_util/tuple/cons/101960.cc: Check tuples with array elements before the last element. diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple index 94a4f0afd31..aaee0b8826a 100644 --- a/libstdc++-v3/include/std/tuple +++ b/libstdc++-v3/include/std/tuple @@ -298,13 +298,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // 2729. Missing SFINAE on std::pair::operator= _Tuple_impl& operator=(const _Tuple_impl&) = delete; - constexpr - _Tuple_impl(_Tuple_impl&& __in) - noexcept(__and_, - is_nothrow_move_constructible<_Inherited>>::value) - : _Inherited(std::move(_M_tail(__in))), - _Base(std::forward<_Head>(_M_head(__in))) - { } + _Tuple_impl(_Tuple_impl&&) = default; template constexpr diff --git a/libstdc++-v3/testsuite/20_util/tuple/cons/101960.cc b/libstdc++-v3/testsuite/20_util/tuple/cons/101960.cc index f14604cdc69..42d17b182ed 100644 --- a/libstdc++-v3/testsuite/20_util/tuple/cons/101960.cc +++ b/libstdc++-v3/testsuite/20_util/tuple/cons/101960.cc @@ -1,4 +1,13 @@ // { dg-do compile { target c++11 } } #include + +// PR libstdc++/101960 + std::tuple t; -auto tt = std::move(t); // PR libstdc++/101960 +auto tt = std::move(t); + +std::tuple t2; +auto tt2 = std::move(t2); + +std::tuple t3; +auto tt3 = std::move(t3); --1FrMQ6VD5ln1lawX--