When the static assert was generated from instantiations of default member
initializer of class B, the error was not generated for B<1, std::layout_left,
std::layout_left> case, only when -D_GLIBCXX_DEBUG was set. Changing B calls to
functions fixes that.

libstdc++-v3/ChangeLog:

        * include/std/mdspan (__mdspan::__mapping_alike): Rename template
        parameter from M to _M_p.
        (layout_stride::mapping): Fix typo in comment.
        * 23_containers/mdspan/layouts/class_mandate_neg.cc: Changed B to
        function.
---
This patch add minor fixes suggeted by Daniel. It also reworks a bit
class_mandate_neg.cc test, as previously one error was not generated
when debug was enabled.

 libstdc++-v3/include/std/mdspan                | 18 +++++++++---------
 .../mdspan/layouts/class_mandate_neg.cc        | 18 ++++++++++--------
 2 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/libstdc++-v3/include/std/mdspan b/libstdc++-v3/include/std/mdspan
index 4a3e863bed5..fbb85fe3f73 100644
--- a/libstdc++-v3/include/std/mdspan
+++ b/libstdc++-v3/include/std/mdspan
@@ -780,16 +780,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   namespace __mdspan
   {
-    template<typename M>
+    template<typename _Mp>
       concept __mapping_alike = requires
       {
-       requires __is_extents<typename M::extents_type>;
-       { M::is_always_strided() } -> same_as<bool>;
-       { M::is_always_exhaustive() } -> same_as<bool>;
-       { M::is_always_unique() } -> same_as<bool>;
-       bool_constant<M::is_always_strided()>::value;
-       bool_constant<M::is_always_exhaustive()>::value;
-       bool_constant<M::is_always_unique()>::value;
+       requires __is_extents<typename _Mp::extents_type>;
+       { _Mp::is_always_strided() } -> same_as<bool>;
+       { _Mp::is_always_exhaustive() } -> same_as<bool>;
+       { _Mp::is_always_unique() } -> same_as<bool>;
+       bool_constant<_Mp::is_always_strided()>::value;
+       bool_constant<_Mp::is_always_exhaustive()>::value;
+       bool_constant<_Mp::is_always_unique()>::value;
       };
 
     template<typename _Mapping>
@@ -847,7 +847,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       mapping() noexcept
       {
        // The precondition is either statically asserted, or automatically
-       // satisfied because dynamic extents are zero-initialzied.
+       // satisfied because dynamic extents are zero-initialized.
        size_t __stride = 1;
        for (size_t __i = extents_type::rank(); __i > 0; --__i)
          {
diff --git 
a/libstdc++-v3/testsuite/23_containers/mdspan/layouts/class_mandate_neg.cc 
b/libstdc++-v3/testsuite/23_containers/mdspan/layouts/class_mandate_neg.cc
index 70a25707cb2..7091153daba 100644
--- a/libstdc++-v3/testsuite/23_containers/mdspan/layouts/class_mandate_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/mdspan/layouts/class_mandate_neg.cc
@@ -18,7 +18,8 @@ template<typename Layout>
   };
 
 template<size_t Count, typename Layout, typename OLayout>
-  struct B
+  bool
+  B()
   {
     using Extents = std::extents<uint8_t, dyn, dyn, Count>;
     using OExtents = std::extents<uint16_t, n, 4, Count>;
@@ -27,20 +28,21 @@ template<size_t Count, typename Layout, typename OLayout>
     using OMapping = typename OLayout::mapping<OExtents>;
 
     Mapping m{OMapping{}};
+    return true;
   };
 
 A<std::layout_left> a_left;                      // { dg-error "required from" 
}
 A<std::layout_right> a_right;                    // { dg-error "required from" 
}
 A<std::layout_stride> a_stride;                  // { dg-error "required from" 
}
 
-B<1, std::layout_left, std::layout_left> b0;     // { dg-error "required here" 
}
-B<2, std::layout_left, std::layout_stride> b1;   // { dg-error "required here" 
}
+auto b1 = B<1, std::layout_left, std::layout_left>();     // { dg-error 
"required from" }
+auto b2 = B<2, std::layout_left, std::layout_stride>();   // { dg-error 
"required from" }
 
-B<3, std::layout_right, std::layout_right> b2;   // { dg-error "required here" 
}
-B<4, std::layout_right, std::layout_stride> b3;  // { dg-error "required here" 
}
+auto b3 = B<3, std::layout_right, std::layout_right>();   // { dg-error 
"required from" }
+auto b4 = B<4, std::layout_right, std::layout_stride>();  // { dg-error 
"required from" }
 
-B<5, std::layout_stride, std::layout_right> b4;  // { dg-error "required here" 
}
-B<6, std::layout_stride, std::layout_left> b5;   // { dg-error "required here" 
}
-B<7, std::layout_stride, std::layout_stride> b6; // { dg-error "required here" 
}
+auto b5 = B<5, std::layout_stride, std::layout_right>();  // { dg-error 
"required from" }
+auto b6 = B<6, std::layout_stride, std::layout_left>();   // { dg-error 
"required from" }
+auto b7 = B<7, std::layout_stride, std::layout_stride>(); // { dg-error 
"required from" }
 
 // { dg-prune-output "must be representable as index_type" }
-- 
2.49.0

Reply via email to