https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121143

--- Comment #6 from Tomasz KamiƄski <tkaminsk at gcc dot gnu.org> ---
I was able to silence the warning by placing the bound on output range, instead
of input:
{
  const auto __sz = ranges::distance(__rg);
  if (__sz > (_Nm - size()))
    __throw_bad_alloc();
  // Bounded on output range due PR121143
  ranges::uninitialized_copy(
    ranges::begin(__rg), unreachable_sentinel,
    data() + _M_size, data() + _M_size + __sz);
  _M_size += size_type(__sz);
}

So instead of copying __sz element for begin(__rg), we copy from begin(__rg)
until __sz elements are copied. The false-positive still remains.

Reply via email to