https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88881
Bug ID: 88881 Summary: std::filesystem::status gives bad results on mingw32 Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org Target Milestone: --- // { dg-options "-std=gnu++17" } #include <filesystem> #include <iostream> void print_status(std::filesystem::path p) { std::cout << p << " exists? " << std::boolalpha << exists(p) << '\n'; } int main() { print_status("./"); print_status("./nonexistent-path/.."); print_status("./nonexistent-path/../"); } This prints: "./" exists? false "./nonexistent-path/.." exists? true "./nonexistent-path/../" exists? false It seems that mingw's stat() fails for a directory with a trailing slash. It also implicitly resolves .. components, without consideration for whether the previous component exists or not (which seems consistent with DOS commands, e.g. "cd .\kgjhfjfj\.." is equivalent to "cd .", but is not how stat is supposed to work). I'll report these to mingw32-w64 but will need to add workarounds to std::filesystem.