On Fri, 31 Oct 2025 at 12:44, Luc Grosheintz <[email protected]> wrote: > > > On 10/31/25 11:09, Jonathan Wakely wrote: > > On Fri, 31 Oct 2025 at 08:23, Luc Grosheintz wrote: > >> > >> These three changes are needed to make <mdspan> compatible with Clang: > >> > >> - the type alias _Storage must occur before its first use. > >> > >> - the friend declarations of function must match exactly, including > >> noexcept and constexpr. > > > > Clang is correct here, GCC has a bug where it doesn't check the > > declarations match. > > > >> > >> - the 'template' in typename T::template type<double>. > > > > I think Clang is correct here too. > > > > I'll apply this for you, thanks. > > Thank you! Please let me know if you'd like me to search bugzilla > to check if these are already known (and report them on the off > chance they're not).
The friend one is https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118381 I'm pretty sure we have an accepts-invalid bug for the template keyword, but I didn't find it from a quick search. > > > > > > >> > >> libstdc++-v3/ChangeLog: > >> > >> * include/std/mdspan (extents::_Storage): Move type alias before > >> its first use. > >> (__mdspan::__static_extents): Add missing noexcept and constexpr > >> to friend declaration in extents. > >> (__mdspan::__dynamic_extents): Ditto. > >> > >> Signed-off-by: Luc Grosheintz <[email protected]> > >> --- > >> libstdc++-v3/include/std/mdspan | 22 ++++++++++++---------- > >> 1 file changed, 12 insertions(+), 10 deletions(-) > >> > >> diff --git a/libstdc++-v3/include/std/mdspan > >> b/libstdc++-v3/include/std/mdspan > >> index d555b7f2580..bd7a2a201a7 100644 > >> --- a/libstdc++-v3/include/std/mdspan > >> +++ b/libstdc++-v3/include/std/mdspan > >> @@ -378,6 +378,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > >> static_assert( > >> (__mdspan::__valid_static_extent<_Extents, _IndexType> && ...), > >> "Extents must either be dynamic or representable as IndexType"); > >> + > >> + using _Storage = __mdspan::_ExtentsStorage< > >> + _IndexType, array<size_t, sizeof...(_Extents)>{_Extents...}>; > >> + [[no_unique_address]] _Storage _M_exts; > >> + > >> public: > >> using index_type = _IndexType; > >> using size_type = make_unsigned_t<index_type>; > >> @@ -487,15 +492,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > >> } > >> > >> private: > >> - friend const array<size_t, rank()>& > >> - __mdspan::__static_extents<extents>(); > >> + friend constexpr const array<size_t, rank()>& > >> + __mdspan::__static_extents<extents>() noexcept; > >> > >> - friend span<const index_type> > >> - __mdspan::__dynamic_extents<extents>(const extents&, size_t, > >> size_t); > >> - > >> - using _Storage = __mdspan::_ExtentsStorage< > >> - _IndexType, array<size_t, sizeof...(_Extents)>{_Extents...}>; > >> - [[no_unique_address]] _Storage _M_exts; > >> + friend constexpr span<const index_type> > >> + __mdspan::__dynamic_extents<extents>(const extents&, size_t, size_t) > >> + noexcept; > >> > >> template<typename _OIndexType, size_t... _OExtents> > >> friend class extents; > >> @@ -1637,8 +1639,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > >> > >> template<typename _OExtents> > >> constexpr explicit > >> - _PaddedStorage(const typename _LayoutSame::mapping<_OExtents>& > >> - __other) > >> + _PaddedStorage( > >> + const typename _LayoutSame::template mapping<_OExtents>& > >> __other) > >> : _PaddedStorage(_Extents(__other.extents())) > >> { > >> constexpr size_t __stride_idx = _LayoutTraits::_S_stride_idx; > >> -- > >> 2.51.1 > >> > > >
