]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Improve static assert messages
authorJonathan Wakely <jwakely@redhat.com>
Thu, 6 May 2021 14:28:55 +0000 (15:28 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Thu, 6 May 2021 15:07:10 +0000 (16:07 +0100)
The message used for static assertions should be phrased so that it's
unambiguous whether the condition should be true or false. The message
should definitely not state the negative condition.

libstdc++-v3/ChangeLog:

* include/bits/stl_algobase.h (__copy_move, __copy_move_backward):
Improve static_assert messages.
* testsuite/25_algorithms/copy/58982.cc: Adjust expected output.
* testsuite/25_algorithms/copy_n/58982.cc: Likewise.

libstdc++-v3/include/bits/stl_algobase.h
libstdc++-v3/testsuite/25_algorithms/copy/58982.cc
libstdc++-v3/testsuite/25_algorithms/copy_n/58982.cc

index a76b00bda756424cd54fcfc9d11bf7bdd9cd90d9..d001b5f9dae65eb28e943730e4d252a905db4072 100644 (file)
@@ -424,7 +424,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
                                           is_move_assignable<_Tp>,
                                           is_copy_assignable<_Tp>>;
          // trivial types can have deleted assignment
-         static_assert( __assignable::type::value, "type is not assignable" );
+         static_assert( __assignable::type::value, "type must be assignable" );
 #endif
          const ptrdiff_t _Num = __last - __first;
          if (_Num)
@@ -735,7 +735,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
                                           is_move_assignable<_Tp>,
                                           is_copy_assignable<_Tp>>;
          // trivial types can have deleted assignment
-         static_assert( __assignable::type::value, "type is not assignable" );
+         static_assert( __assignable::type::value, "type must be assignable" );
 #endif
          const ptrdiff_t _Num = __last - __first;
          if (_Num)
index f47bf9f3e458a7fc6ac60a310b598ba8754d21f3..151a7e25ba238a74d0d163364bff2b319bd3830c 100644 (file)
@@ -38,5 +38,5 @@ test01(T* result)
   T t[1];
   std::copy(t, t+1, result); // { dg-error "here|deleted" }
 }
-// { dg-prune-output "not assignable" }
+// { dg-prune-output "type must be assignable" }
 // { dg-prune-output "use of deleted" }
index 133a2e2ed8fa7770b9b7fd1fdeb5522fe912c3f0..5ddc8ccee5e542f69dacfa0e7307df377af022ef 100644 (file)
@@ -38,5 +38,5 @@ test01(T* result)
   T t[1];
   std::copy_n(t, 1, result); // { dg-error "here|deleted" }
 }
-// { dg-prune-output "not assignable" }
+// { dg-prune-output "type must be assignable" }
 // { dg-prune-output "use of deleted" }