[gcc r12-579] libstdc++: Improve static assert messages

Jonathan Wakely redi@gcc.gnu.org
Thu May 6 15:24:50 GMT 2021


https://gcc.gnu.org/g:07dd185755a791ab19e6a63274cf2cb69f087a6c

commit r12-579-g07dd185755a791ab19e6a63274cf2cb69f087a6c
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu May 6 15:28:55 2021 +0100

    libstdc++: Improve static assert messages
    
    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.

Diff:
---
 libstdc++-v3/include/bits/stl_algobase.h             | 4 ++--
 libstdc++-v3/testsuite/25_algorithms/copy/58982.cc   | 2 +-
 libstdc++-v3/testsuite/25_algorithms/copy_n/58982.cc | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libstdc++-v3/include/bits/stl_algobase.h b/libstdc++-v3/include/bits/stl_algobase.h
index a76b00bda75..d001b5f9dae 100644
--- a/libstdc++-v3/include/bits/stl_algobase.h
+++ b/libstdc++-v3/include/bits/stl_algobase.h
@@ -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)
diff --git a/libstdc++-v3/testsuite/25_algorithms/copy/58982.cc b/libstdc++-v3/testsuite/25_algorithms/copy/58982.cc
index f47bf9f3e45..151a7e25ba2 100644
--- a/libstdc++-v3/testsuite/25_algorithms/copy/58982.cc
+++ b/libstdc++-v3/testsuite/25_algorithms/copy/58982.cc
@@ -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" }
diff --git a/libstdc++-v3/testsuite/25_algorithms/copy_n/58982.cc b/libstdc++-v3/testsuite/25_algorithms/copy_n/58982.cc
index 133a2e2ed8f..5ddc8ccee5e 100644
--- a/libstdc++-v3/testsuite/25_algorithms/copy_n/58982.cc
+++ b/libstdc++-v3/testsuite/25_algorithms/copy_n/58982.cc
@@ -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" }


More information about the Libstdc++-cvs mailing list