[gcc r16-5987] libstdc++: Silence warning in mdspan.

Tomasz Kaminski tkaminsk@gcc.gnu.org
Tue Dec 9 12:27:25 GMT 2025


https://gcc.gnu.org/g:64d5e1eb97f198c9377c393d648c8db2617a80d0

commit r16-5987-g64d5e1eb97f198c9377c393d648c8db2617a80d0
Author: Luc Grosheintz <luc.grosheintz@gmail.com>
Date:   Mon Dec 8 21:23:40 2025 +0100

    libstdc++: Silence warning in mdspan.
    
    Splitting the tests for submdspan triggered a compiler warning. This
    commit changes the implementation of __dynamic_extents. In particular,
    how the span is created. Functionally, the two are equivalent.
    
    libstdc++-v3/ChangeLog:
    
            * include/std/mdspan (_ExtentsStorage::_M_dynamic_extents):
            Create span from pointer + size, not begin and end iterators.
    
    Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
    Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>

Diff:
---
 libstdc++-v3/include/std/mdspan | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libstdc++-v3/include/std/mdspan b/libstdc++-v3/include/std/mdspan
index 981fa1c601a1..f0f6630b4729 100644
--- a/libstdc++-v3/include/std/mdspan
+++ b/libstdc++-v3/include/std/mdspan
@@ -271,7 +271,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	requires (_Extents.size() > 0)
 	{
 	  return {_M_dyn_exts + _S_dynamic_index(__begin),
-		  _M_dyn_exts + _S_dynamic_index(__end)};
+		  _S_dynamic_index(__end) - _S_dynamic_index(__begin)};
 	}
 
       private:


More information about the Gcc-cvs mailing list