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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I think the behaviour you're seeing is correct (and Clang gives the same
result). The problem is that increments to the input iterator happen inside the
copy_n call, to a copy of the iterator not to readIter itself. This means it is
not equivalent to your for (int j = 0; j < 4; ++j) loop which operates directly
on readIter.

Each time through the outer loop the readIter variable has not been
incremented, so has not cached the next element from the input stream.

Reply via email to