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

            Bug ID: 98985
           Summary: libstdc++: filesystem::rename not overwriting files on
                    Windows
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: m.heinzler at heinzler dot de
  Target Milestone: ---

Created attachment 50139
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50139&action=edit
Proposed fix

filesystem::rename must replace existing files and currently does so on most
platforms by simply calling posix::rename. But on Windows (specifically MinGW),
posix::rename refers to Microsoft's MSVCRT which does not overwrite files.
See:
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/rename-wrename?view=msvc-160

I attached a patch that falls back to the WinAPI in this case and tested it
successfully. This is also how Microsoft implements filesystem::rename.

As I'm not familiar with the codebase I wasn't able to add a simple test case
for this. If someone could give me a hint which files to touch I could also
work on that.

Reply via email to