https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100833
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-10 branch has been updated by Jonathan Wakely <r...@gcc.gnu.org>: https://gcc.gnu.org/g:753c8680a46d371e179ff1ade36002486361095e commit r10-9887-g753c8680a46d371e179ff1ade36002486361095e Author: Jonathan Wakely <jwak...@redhat.com> Date: Tue Jun 1 16:02:45 2021 +0100 libstdc++: Fix return value of std::ranges::advance [PR 100833] The three-argument form of ranges::advance is supposed to return the difference between the second argument and the distance the iterator was advanced. When a non-random-access iterator is not advanced (because it already equals the sentinel) we were returning 0 rather than n - 0. libstdc++-v3/ChangeLog: PR libstdc++/100833 * include/bits/range_access.h (ranges::advance(iter, n, sentinel)): Fix return value for no-op case. * testsuite/24_iterators/range_operations/advance.cc: Test return values of three-argument overload. (cherry picked from commit d8326291695c0f13124c232ddf4fd34e3310e649)