]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Add noexcept to bad_expected_access<void> members (LWG 4031)
authorJonathan Wakely <jwakely@redhat.com>
Wed, 26 Jun 2024 13:15:29 +0000 (14:15 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Thu, 25 Jul 2024 10:53:06 +0000 (11:53 +0100)
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.

libstdc++-v3/include/std/expected
libstdc++-v3/testsuite/20_util/expected/bad.cc

index 2594cfe131c08b9e94efe5867f260f05dc7c59db..3c52f7db01e2663d8ae8d63a82255247c52beffd 100644 (file)
@@ -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:
index c629e149da5c0f93927f066ced097f6a03a22c49..7e227f904a02f269ef6c64cbd9b1542d5d9f0236 100644 (file)
@@ -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> );
+}