diff --git 
a/libstdc++-v3/testsuite/23_containers/mdspan/extents/assign_copy_01_neg.cc 
b/libstdc++-v3/testsuite/23_containers/mdspan/extents/assign_copy_01_neg.cc
new file mode 100644
index 00000000000..8a514f2207b
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/mdspan/extents/assign_copy_01_neg.cc
@@ -0,0 +1,15 @@
+// { dg-do compile { target c++23 } }
+#include <mdspan>
+
+constexpr auto dyn = std::dynamic_extent;
+
+void
+test_assigment()
+{
+  auto e1 = std::extents<int, 1, 2>();
+  auto e2 = std::extents<int, 1, dyn>();
+
+  e1 = e2;
+}
+
+// { dg-error "no match for 'operator=" "" { target *-*-* } 12 }


Could most of these negative *_neg.cc tests be replaced by checks like
static_assert( ! std::is_copy_assignable_v<...> ) in the corresponding
positive test, e.g. assign_copy.cc in this case?

Every separate test file has a small but measurable startup cost for
the testsuite, and we already have 10k test files!
If we can verify the same behaviour using concepts or traits, we don't
need a separate neg.cc test.
Sometimes we really do want a separate test, because we want to check
that there's a specific error message, or we want to check for a
static_assert inside a function body which can't be checked using
concepts and so really does need to use dg-error, but I don't think
that appies here. The string you're matching is just the generic "no
match" error from the compiler.


Yes, I'll restructure the tests as proposed.

Reply via email to