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

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Actually it's nothing to do with operating on a copy of the iterator, it's due
to this in the implementation of copy_n:

    if (--__n  > 0)
      ++__first;

So as you observe we don't increment the input iterator on the last step.
However, I don't see any requirement in the standard that says we're supposed
to do so. All that is required is n assignments, there is no guarantee that the
input range is also incremented past the last element written to. So I think
you are assuming something that isn't actually guaranteed by the standard.

Reply via email to