[PATCH v2 1/2] libstdc++: Reduce size static storage for __fwd_prod in mdspan.

Luc Grosheintz luc.grosheintz@gmail.com
Mon Aug 11 20:14:54 GMT 2025


This fixes an oversight in a previous commit that improved mdspan
related code. Because __size doesn't use __fwd_prod, __fwd_prod(__rank)
is not needed anymore. Hence, one can shrink the size of
__fwd_partial_prods.

libstdc++-v3/ChangeLog:

	* include/std/mdspan (__fwd_partial_prods): Reduce size of the
	array by 1 element.

Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
---
 libstdc++-v3/include/std/mdspan | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/include/std/mdspan b/libstdc++-v3/include/std/mdspan
index 351018a59a5..8f974257e96 100644
--- a/libstdc++-v3/include/std/mdspan
+++ b/libstdc++-v3/include/std/mdspan
@@ -274,8 +274,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       constexpr auto __fwd_partial_prods = [] consteval
 	{
 	  constexpr size_t __rank = _Extents.size();
-	  std::array<size_t, __rank + 1> __ret;
-	  for(size_t __r = 0; __r < __rank + 1; ++__r)
+	  std::array<size_t, __rank> __ret;
+	  for(size_t __r = 0; __r < __rank; ++__r)
 	    __ret[__r] = __static_prod<_Extents>(0, __r);
 	  return __ret;
 	}();
-- 
2.50.0



More information about the Libstdc++ mailing list