public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org
Subject: [gcc r11-9116] libstdc++: Fix move construction of std::tuple with array elements [PR101960]
Date: Tue, 12 Oct 2021 10:59:48 +0000 (GMT)	[thread overview]
Message-ID: <20211012105948.E7A7B3857C71@sourceware.org> (raw)

https://gcc.gnu.org/g:00967465fe8093661a4d42356821eeb04170e09d

commit r11-9116-g00967465fe8093661a4d42356821eeb04170e09d
Author: Jonathan Wakely <jwakely@redhat.com>
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 <jwakely@redhat.com>
    
    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.
    
    (cherry picked from commit 0187e0d7360f327f88d8b2294668669306ae4630)

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 d2574a3a7cc..23fad918c57 100644
--- a/libstdc++-v3/include/std/tuple
+++ b/libstdc++-v3/include/std/tuple
@@ -453,11 +453,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<typename _UHead>
 	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 <tuple>
+std::tuple<int[1]> t;
+auto tt = std::move(t); // PR libstdc++/101960


                 reply	other threads:[~2021-10-12 10:59 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211012105948.E7A7B3857C71@sourceware.org \
    --to=redi@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    --cc=libstdc++-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).