aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2022-04-08 18:04:04 +0100
committerJonathan Wakely <jwakely@redhat.com>2022-04-08 18:30:06 +0100
commit29e355d0d671c7474935220e8bef784f05143820 (patch)
tree498b0364c3ce34006a0af5690b85ca8dc0167b19
parent5522dec054cb940fe83661b96249aa12c54c1d77 (diff)
downloadgcc-29e355d0d671c7474935220e8bef784f05143820.zip
gcc-29e355d0d671c7474935220e8bef784f05143820.tar.gz
gcc-29e355d0d671c7474935220e8bef784f05143820.tar.bz2
libstdc++: Fix std::bad_expected_access constructor [PR105146]
libstdc++-v3/ChangeLog: PR libstdc++/105146 * include/std/expected (bad_expected_access): Move constructor parameter. * testsuite/20_util/expected/bad.cc: New test.
-rw-r--r--libstdc++-v3/include/std/expected2
-rw-r--r--libstdc++-v3/testsuite/20_util/expected/bad.cc15
2 files changed, 16 insertions, 1 deletions
diff --git a/libstdc++-v3/include/std/expected b/libstdc++-v3/include/std/expected
index 39d07cd..7b01a17 100644
--- a/libstdc++-v3/include/std/expected
+++ b/libstdc++-v3/include/std/expected
@@ -95,7 +95,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
class bad_expected_access : public bad_expected_access<void> {
public:
explicit
- bad_expected_access(_Er __e) : _M_val(__e) { }
+ bad_expected_access(_Er __e) : _M_val(std::move(__e)) { }
// XXX const char* what() const noexcept override;
diff --git a/libstdc++-v3/testsuite/20_util/expected/bad.cc b/libstdc++-v3/testsuite/20_util/expected/bad.cc
new file mode 100644
index 0000000..17bc6d6
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/expected/bad.cc
@@ -0,0 +1,15 @@
+// { dg-options "-std=gnu++23" }
+// { dg-do compile }
+
+#include <expected>
+
+struct E {
+ E() = default;
+ E(E&&) = default;
+};
+
+void
+test_pr105146()
+{
+ std::bad_expected_access(E{});
+}