https://gcc.gnu.org/g:90f7bbfe2219770ac8b25d0f99320ed3a4fd7736
commit r16-1474-g90f7bbfe2219770ac8b25d0f99320ed3a4fd7736 Author: Tomasz Kamiński <tkami...@redhat.com> Date: Thu Jun 5 10:40:10 2025 +0200 libstdc++: Uglify __mapping_alike template parameter and fix test and typo in comment. 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. We also replace class with typename in template head of layout_right::mapping constructors. libstdc++-v3/ChangeLog: * include/std/mdspan (__mdspan::__mapping_alike): Rename template parameter from M to _M_p. (layout_right::mapping): Replace class with typename in template head. (layout_stride::mapping): Fix typo in comment. * testsuite/23_containers/mdspan/layouts/class_mandate_neg.cc: Changed B to function. Reviewed-by: Jonathan Wakely <jwak...@redhat.com> Signed-off-by: Tomasz Kamiński <tkami...@redhat.com> Diff: --- libstdc++-v3/include/std/mdspan | 22 +++++++++++----------- .../mdspan/layouts/class_mandate_neg.cc | 18 ++++++++++-------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/libstdc++-v3/include/std/mdspan b/libstdc++-v3/include/std/mdspan index 4a3e863bed5f..6dc2441f80bd 100644 --- a/libstdc++-v3/include/std/mdspan +++ b/libstdc++-v3/include/std/mdspan @@ -691,7 +691,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : mapping(__other.extents(), __mdspan::__internal_ctor{}) { } - template<class _OExtents> + template<typename _OExtents> requires (extents_type::rank() <= 1) && is_constructible_v<extents_type, _OExtents> constexpr explicit(!is_convertible_v<_OExtents, extents_type>) @@ -699,7 +699,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : mapping(__other.extents(), __mdspan::__internal_ctor{}) { } - template<class _OExtents> + template<typename _OExtents> requires is_constructible_v<extents_type, _OExtents> constexpr explicit(extents_type::rank() > 0) mapping(const layout_stride::mapping<_OExtents>& __other) noexcept @@ -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 70a25707cb2a..7091153daba8 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" }