In case of input iterators, the loop that assigns to existing elements
should run up to number of elements in vector (_M_size) not capacity (_Nm).

        PR libstdc++/119137

libstdc++-v3/ChangeLog:

        * include/std/inplace_vector (inplace_vector::assign_range):
        Replace _Nm with _M_size in the assigment loop.
---
This obvious type was detected by adding more constexpr test, that I will post 
later.
Committing it direclty, as this is new C++26 code.

Pushed to trunk.

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

diff --git a/libstdc++-v3/include/std/inplace_vector 
b/libstdc++-v3/include/std/inplace_vector
index e0943f52ab8..290cf6eb0e9 100644
--- a/libstdc++-v3/include/std/inplace_vector
+++ b/libstdc++-v3/include/std/inplace_vector
@@ -269,7 +269,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
              auto __in = ranges::begin(__rg);
              auto __end = ranges::end(__rg);
              size_type __n = 0;
-             for (; __n < _Nm && __in != __end; ++__in)
+             for (; __n < _M_size && __in != __end; ++__in)
                _M_elems[__n++] = *__in;
 
              if (__in == __end)
-- 
2.49.0

Reply via email to