https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97731
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-8 branch has been updated by Jonathan Wakely <r...@gcc.gnu.org>: https://gcc.gnu.org/g:749cfa1f150d1e0749feb7aed8f68b8d0294b03f commit r8-10616-g749cfa1f150d1e0749feb7aed8f68b8d0294b03f Author: Jonathan Wakely <jwak...@redhat.com> Date: Thu Nov 5 17:26:13 2020 +0000 libstdc++: Use non-throwing increment in recursive_directory_iterator [PR 97731] As described in the PR, the recursive_directory_iterator constructor calls advance(ec), but ec is a pointer so it calls _Dir::advance(bool). The intention was to either call advance() or advance(*ec) depending whether the pointer is null or not. This fixes the bug and renames the parameter to ecptr to make similar mistakes less likely in future. libstdc++-v3/ChangeLog: PR libstdc++/97731 * src/filesystem/dir.cc (recursive_directory_iterator): Call the right overload of _Dir::advance. * testsuite/experimental/filesystem/iterators/97731.cc: New test. (cherry picked from commit 2f93a2a03a343a29f614a530d7657f1ed6347ed5)