https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121061
--- Comment #5 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:29d53f6213e0a1569aa8ca9db613b48df642986c commit r16-2328-g29d53f6213e0a1569aa8ca9db613b48df642986c Author: Luc Grosheintz <luc.groshei...@gmail.com> Date: Wed Jul 16 15:45:45 2025 +0200 libstdc++: Fix forwarding of custom IndexType in mdspan [PR121061] The second bug report in PR121061 is that the conversion of custom OtherIndexType to IndexType is incorrectly not done via r-value references. This commit fixes the forwarding issue, adds a custom IndexType called RValueInt, which only allows conversion to int via r-value reference. PR libstdc++/121061 libstdc++-v3/ChangeLog: * include/std/mdspan (extents::extents): Perform conversion to index_type of an r-value reference. (layout_left::mapping::operator()): Ditto. (layout_right::mapping::operator()): Ditto. (layout_stride::mapping::operator()): Ditto. * testsuite/23_containers/mdspan/extents/custom_integer.cc: Add tests for RValueInt and MutatingInt. * testsuite/23_containers/mdspan/int_like.h (RValueInt): Add. * testsuite/23_containers/mdspan/layouts/mapping.cc: Test with RValueInt. * 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>