]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Fix obvious mistake in inplace_vector::assign_range [PR119137]
authorTomasz Kamiński <tkaminsk@redhat.com>
Tue, 22 Jul 2025 07:32:47 +0000 (09:32 +0200)
committerTomasz Kamiński <tkaminsk@redhat.com>
Tue, 22 Jul 2025 07:33:05 +0000 (09:33 +0200)
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.

libstdc++-v3/include/std/inplace_vector

index e0943f52ab8323c25a52016f936c8527a355c198..290cf6eb0e929cbca03005ff301b30ca49c59969 100644 (file)
@@ -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)