https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97731
--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jonathan Wakely <r...@gcc.gnu.org>: https://gcc.gnu.org/g:2f93a2a03a343a29f614a530d7657f1ed6347ed5 commit r11-4750-g2f93a2a03a343a29f614a530d7657f1ed6347ed5 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.