https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99533
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Last reconfirmed| |2021-03-11 Status|UNCONFIRMED |NEW --- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Steffen Schuemann from comment #0) > On POSIX filesystem backend type systems the > std::filesystem::recursive_directory_iterator throws a filesystem_error > exception with "operation not permitted" when the opendir/readdir call > returns EPERM instead of EACCES even if > std::filesystem::directory_options::skip_permission_denied is set. POSIX is clear that opendir sets EACCES not EPERM. > Given the following code: > > #include <iostream> > #include <filesystem> N.B. This is missing a "namespace fs = std::filesystem;" > This fails for example on macOS when called on the user home directory with: > > Error: filesystem error: cannot increment recursive directory iterator: > Operation not permitted > > This is due to System Integrity Protection (since macOS 10.14) on the > "/Users/<user>/Library/Application Support/MobileSync" folder leading to > EPERM. That seems to be a MacOS bug. > On Linux, called with / it stops when hitting for example a > "/proc/1/task/1/cwd", resulting in EPERM too. But that happens in your code, not in the library. The error is: Error: filesystem error: status: Permission denied [/proc/1/task/1/cwd] And it comes from this line: if(de.is_regular_file()) { I think the code is working correctly on linux.