https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121061
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Tomasz Kaminski <tkami...@gcc.gnu.org>: https://gcc.gnu.org/g:1eee8430794f790b6d364603685e70d83d8d42f5 commit r16-2327-g1eee8430794f790b6d364603685e70d83d8d42f5 Author: Luc Grosheintz <luc.groshei...@gmail.com> Date: Wed Jul 16 15:45:44 2025 +0200 libstdc++: Fix constraint for custom integer types in mdspan [PR121061] PR121061 consists of two bugs for mdspan related code. This commit fixes the first one. Namely, when passing custom IndexType as an array or span, the conversion to int must be const. Prior to this commit the constraint incorrectly also allowed non-const conversion. This commit updates all related constraints to check __valid_index_type<const OtherIndexType&, index_type> in those cases. Also adds a MutatingInt to int_like.h which only supports non-const conversion to int and updates the tests. PR libstdc++/121061 libstdc++-v3/ChangeLog: * include/std/mdspan (extents::extents): Fix constraint to prevent non-const conversion to index_type. (layout_stride::mapping::mapping): Ditto. (mdspan::mdspan): Ditto. (mdspan::operator[]): Ditto. * testsuite/23_containers/mdspan/extents/custom_integer.cc: Add test for MutatingInt. * testsuite/23_containers/mdspan/int_like.h (MutatingInt): Add. * testsuite/23_containers/mdspan/layouts/mapping.cc: Add test for MutatingInt. * testsuite/23_containers/mdspan/layouts/stride.cc: Ditto. * testsuite/23_containers/mdspan/mdspan.cc: Ditto. Reviewed-by: Jonathan Wakely <jwak...@redhat.com> Reviewed-by: Tomasz KamiÅski <tkami...@redhat.com> Signed-off-by: Luc Grosheintz <luc.groshei...@gmail.com>