https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121061

Tomasz Kamiński <tkaminsk at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2025-07-14

--- Comment #2 from Tomasz Kamiński <tkaminsk at gcc dot gnu.org> ---
Related to above, the following is ill-formed:
```
class IntLike
{
public:
  explicit
  IntLike(int i)
  : _M_i(i)
  { }


  constexpr
  operator int() && noexcept
  { return _M_i; }


private:
  int _M_i;
};


IntLike il(1);
static_assert(std::is_constructible_v<std::extents<int, std::dynamic_extent>,
IntLike>);
std::extents<int, std::dynamic_extent> e1(std::move(il));
```
See: https://godbolt.org/z/hnd6zbde5

This is because, we do not move the index in constructor:
      template<__mdspan::__valid_index_type<index_type>... _OIndexTypes>
        requires (sizeof...(_OIndexTypes) == rank()
                  || sizeof...(_OIndexTypes) == rank_dynamic())
        constexpr explicit extents(_OIndexTypes... __exts) noexcept
        : _M_exts(span<const _IndexType, sizeof...(_OIndexTypes)>(
            initializer_list{_S_storage::_S_int_cast(__exts)...}))
        { }
`__exts` should be moved here, and _S_int_cast needs to be changed to be
forwarding.

This affects also operators() and mdspan/extents constructors.

Reply via email to