aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2021-08-19 11:48:40 +0100
committerJonathan Wakely <jwakely@redhat.com>2021-08-19 13:02:12 +0100
commit0187e0d7360f327f88d8b2294668669306ae4630 (patch)
tree1ce16d446e1ae3cd5b0761c82978f97a7e1a9928
parent926d4a71c7e5a2f7d17a4f943d6e7fe9f1e3ba55 (diff)
downloadgcc-0187e0d7360f327f88d8b2294668669306ae4630.zip
gcc-0187e0d7360f327f88d8b2294668669306ae4630.tar.gz
gcc-0187e0d7360f327f88d8b2294668669306ae4630.tar.bz2
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.
-rw-r--r--libstdc++-v3/include/std/tuple6
-rw-r--r--libstdc++-v3/testsuite/20_util/tuple/cons/101960.cc4
2 files changed, 9 insertions, 1 deletions
diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple
index 1292aee..f082ccb 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<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 0000000..f14604c
--- /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