r280020 - in /branches/gcc-9-branch/libstdc++-v...
redi@gcc.gnu.org
redi@gcc.gnu.org
Wed Jan 8 21:48:00 GMT 2020
Author: redi
Date: Wed Jan 8 21:48:23 2020
New Revision: 280020
URL: https://gcc.gnu.org/viewcvs?rev=280020&root=gcc&view=rev
Log:
libstdc++: Fix error handling in filesystem::remove_all (PR93201)
When recursing into a directory, any errors that occur while removing a
directory entry are ignored, because the subsequent increment of the
directory iterator clears the error_code object.
This fixes that bug by checking the result of each recursive operation
before incrementing. This is a change in observable behaviour, because
previously other directory entries would still be removed even if one
(or more) couldn't be removed due to errors. Now the operation stops on
the first error, which is what the code intended to do all along. The
standard doesn't specify what happens in this case (because the order
that the entries are processed is unspecified anyway).
PR libstdc++/93201
* src/c++17/fs_ops.cc (remove_all(const path&, error_code&)): Check
result of recursive call before incrementing iterator.
* src/filesystem/ops.cc (remove_all(const path&, error_code&)):
Likewise.
* testsuite/27_io/filesystem/operations/remove_all.cc: Check errors
are reported correctly.
* testsuite/experimental/filesystem/operations/remove_all.cc: Likewise.
Modified:
branches/gcc-9-branch/libstdc++-v3/ChangeLog
branches/gcc-9-branch/libstdc++-v3/src/c++17/fs_ops.cc
branches/gcc-9-branch/libstdc++-v3/src/filesystem/ops.cc
branches/gcc-9-branch/libstdc++-v3/testsuite/27_io/filesystem/operations/remove_all.cc
branches/gcc-9-branch/libstdc++-v3/testsuite/experimental/filesystem/operations/remove_all.cc
More information about the Libstdc++-cvs
mailing list