https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64814
--- Comment #2 from Anquietas <alex-j-a at hotmail dot co.uk> --- (In reply to Jonathan Wakely from comment #1) > 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. The copy_n implementation I provided produces the same behaviour as the for loop, even with copying the iterator.