aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2018-04-04 00:03:07 +0100
committerJonathan Wakely <redi@gcc.gnu.org>2018-04-04 00:03:07 +0100
commitc73847e77b379bc6f51f5cda2649fff5ae5b9130 (patch)
treec349cae67afef3d85178a55083da0f8d3a33a680 /libstdc++-v3
parentb6a7a294ce823917dd08e8d5923137ff75b09fae (diff)
downloadgcc-c73847e77b379bc6f51f5cda2649fff5ae5b9130.zip
gcc-c73847e77b379bc6f51f5cda2649fff5ae5b9130.tar.gz
gcc-c73847e77b379bc6f51f5cda2649fff5ae5b9130.tar.bz2
PR libstdc++/85183 fix std::variant move-assignment
PR libstdc++/85183 * include/std/variant (_Move_assign_base::operator=): Fix incorrect value categories. * testsuite/20_util/variant/85183.cc: New. From-SVN: r259059
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog7
-rw-r--r--libstdc++-v3/include/std/variant7
-rw-r--r--libstdc++-v3/testsuite/20_util/variant/85183.cc35
3 files changed, 46 insertions, 3 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index bdd4c6b..df667c1 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,10 @@
+2018-04-03 Jonathan Wakely <jwakely@redhat.com>
+
+ PR libstdc++/85183
+ * include/std/variant (_Move_assign_base::operator=): Fix incorrect
+ value categories.
+ * testsuite/20_util/variant/85183.cc: New.
+
2018-03-26 Jonathan Wakely <jwakely@redhat.com>
* include/std/variant (__get): Qualify calls to avoid ADL.
diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant
index e4ae657..028d306 100644
--- a/libstdc++-v3/include/std/variant
+++ b/libstdc++-v3/include/std/variant
@@ -605,13 +605,14 @@ namespace __variant
if (__rhs._M_valid())
{
static constexpr void (*_S_vtable[])(void*, void*) =
- { &__erased_assign<_Types&, const _Types&>... };
- _S_vtable[__rhs._M_index](this->_M_storage(), __rhs._M_storage());
+ { &__erased_assign<_Types&, _Types&&>... };
+ _S_vtable[__rhs._M_index]
+ (this->_M_storage(), __rhs._M_storage());
}
}
else
{
- _Move_assign_base __tmp(__rhs);
+ _Move_assign_base __tmp(std::move(__rhs));
this->~_Move_assign_base();
__try
{
diff --git a/libstdc++-v3/testsuite/20_util/variant/85183.cc b/libstdc++-v3/testsuite/20_util/variant/85183.cc
new file mode 100644
index 0000000..b122c63
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/variant/85183.cc
@@ -0,0 +1,35 @@
+// Copyright (C) 2018 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++17" }
+// { dg-do compile { target c++17 } }
+
+#include <variant>
+
+struct moveonly {
+ moveonly() noexcept { }
+ moveonly(moveonly&&) noexcept { }
+ moveonly& operator=(moveonly&&) noexcept { return *this; }
+ ~moveonly() { }
+};
+
+void
+test01()
+{
+ std::variant<moveonly> v1, v2;
+ v1 = std::move(v2); // PR libstdc++/85183
+}