https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122726

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2025-11-17

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---

(In reply to Daniel Plakhotich from comment #0)
> Is it possible to create a more complete mapping from GetLastError() to
> std::errc to make rename() errors more useful?

That was done about 6 months after the change you linked to. When I implemented
filesystem::rename it wasn't possible, but this will work now:

--- a/libstdc++-v3/src/filesystem/ops-common.h
+++ b/libstdc++-v3/src/filesystem/ops-common.h
@@ -159,10 +159,7 @@ namespace __gnu_posix
     if (MoveFileExW(oldname, newname,
                    MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED))
       return 0;
-    if (GetLastError() == ERROR_ACCESS_DENIED)
-      errno = EACCES;
-    else
-      errno = EIO;
+    errno = std::__last_error_code().default_error_condition().value();
     return -1;
   }

Reply via email to