aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2024-06-26 14:15:29 +0100
committerThomas Koenig <tkoenig@gcc.gnu.org>2024-07-28 19:05:56 +0200
commitb42f73132c51aece4bed43cdceb4b8cf31197a2b (patch)
treedea107b10996e60543449ec534312087c4c8e2b5
parenta2a6695d8aa63e03bd52351c4435a88a8b78802a (diff)
downloadgcc-b42f73132c51aece4bed43cdceb4b8cf31197a2b.zip
gcc-b42f73132c51aece4bed43cdceb4b8cf31197a2b.tar.gz
gcc-b42f73132c51aece4bed43cdceb4b8cf31197a2b.tar.bz2
libstdc++: Add noexcept to bad_expected_access<void> members (LWG 4031)
libstdc++-v3/ChangeLog: * include/std/expected (bad_expected_access<void>): Add noexcept to special member functions, as per LWG 4031. * testsuite/20_util/expected/bad.cc: Check for nothrow copy and move members.
-rw-r--r--libstdc++-v3/include/std/expected8
-rw-r--r--libstdc++-v3/testsuite/20_util/expected/bad.cc13
2 files changed, 17 insertions, 4 deletions
diff --git a/libstdc++-v3/include/std/expected b/libstdc++-v3/include/std/expected
index 2594cfe..3c52f7d 100644
--- a/libstdc++-v3/include/std/expected
+++ b/libstdc++-v3/include/std/expected
@@ -79,10 +79,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
protected:
bad_expected_access() noexcept { }
- bad_expected_access(const bad_expected_access&) = default;
- bad_expected_access(bad_expected_access&&) = default;
- bad_expected_access& operator=(const bad_expected_access&) = default;
- bad_expected_access& operator=(bad_expected_access&&) = default;
+ bad_expected_access(const bad_expected_access&) noexcept = default;
+ bad_expected_access(bad_expected_access&&) noexcept = default;
+ bad_expected_access& operator=(const bad_expected_access&) noexcept = default;
+ bad_expected_access& operator=(bad_expected_access&&) noexcept = default;
~bad_expected_access() = default;
public:
diff --git a/libstdc++-v3/testsuite/20_util/expected/bad.cc b/libstdc++-v3/testsuite/20_util/expected/bad.cc
index c629e14..7e227f9 100644
--- a/libstdc++-v3/testsuite/20_util/expected/bad.cc
+++ b/libstdc++-v3/testsuite/20_util/expected/bad.cc
@@ -12,3 +12,16 @@ test_pr105146()
{
std::bad_expected_access(E{});
}
+
+void
+test_lwg4031()
+{
+ struct test_type : std::bad_expected_access<void> { };
+
+ static_assert( std::is_nothrow_default_constructible_v<test_type> );
+ // LWG 4031. bad_expected_access<void> member functions should be noexcept
+ static_assert( std::is_nothrow_copy_constructible_v<test_type> );
+ static_assert( std::is_nothrow_move_constructible_v<test_type> );
+ static_assert( std::is_nothrow_copy_assignable_v<test_type> );
+ static_assert( std::is_nothrow_move_assignable_v<test_type> );
+}