https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71415
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |INVALID --- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> --- The semantics of exists(const path&, error_code&) are precisely specified, and I think this behaviour is correct according to the specification. This is also consistent with Boost.Filesystem. (In reply to Martin Ejdestig from comment #0) > Which means it is not possible to discern between an error and when the file > does not exist without examining error_code.value(), which is platform > dependent. Just compare to the platform independent enumerator: #include <experimental/filesystem> #include <iostream> int main() { std::error_code error_code; bool exists = std::experimental::filesystem::exists("does_not_exist", error_code); std::cout << "exists: " << exists << '\n'; std::cout << "an error happened: " << (error_code != std::errc::no_such_file_or_directory) << '\n'; } I'll discuss with the C++ committee whether this behaviour is really desirable, but it seems to be what the spec requires, and not a bug in GCC.