https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88881
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> --- But that fix looks wrong, it means "file/" will resolve to "file" and that's wrong a for a non-directory, because "file/" should fail. Testcase demonstrating the mingw bugs: #include <sys/stat.h> #include <stdio.h> void print(const char* s, int i, int expected) { printf("%-26s %2d %s\n", s, i, i == expected ? "" : " FAIL"); } void f1() { struct stat st; int i; i = stat(".\\", &st); print("stat(\".\\\")", i, 0); i = stat(".\\nonesuch\\..", &st); print("stat(\".\\nonesuch\\..\")", i, -1); // Trailing slash after a non-directory should fail: i = stat("a.exe\\", &st); print("stat(\"a.exe\\\")", i, -1); // "/." after a non-directory is also wrong: i = stat("a.exe\\.", &st); print("stat(\"a.exe\\.\")", i, -1); // And resolving "/dir/.." after a non-directory is also wrong: i = stat("a.exe\\nonesuch\\..", &st); print("stat(\"a.exe\\nonesuch\\..\")", i, -1); } void f2() { struct _stat st; int i; i = _stat(".\\", &st); print("_stat(\".\\\")", i, 0); i = _stat(".\\nonesuch\\..", &st); print("_stat(\".\\nonesuch\\..\")", i, -1); } void f3() { struct _stat st; int i; i = _wstat(L".\\", &st); print("_wstat(L\".\\\")", i, 0); i = _wstat(L".\\nonesuch\\..", &st); print("_wstat(L\".\\nonesuch\\..\")", i, -1); } int main() { f1(); f2(); f3(); } Output for mingw-w64 5.0 stat(".\") 0 stat(".\nonesuch\..") 0 FAIL stat("a.exe\") 0 FAIL stat("a.exe\.") 0 FAIL stat("a.exe\nonesuch\..") 0 FAIL _stat(".\") -1 FAIL _stat(".\nonesuch\..") 0 FAIL _wstat(L".\") -1 FAIL _wstat(L".\nonesuch\..") 0 FAIL