From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 700E5386F82D; Sun, 7 Feb 2021 16:58:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 700E5386F82D From: "m.heinzler at heinzler dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/98985] New: libstdc++: filesystem::rename not overwriting files on Windows Date: Sun, 07 Feb 2021 16:58:30 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 10.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: m.heinzler at heinzler dot de X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Feb 2021 16:58:30 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D98985 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=3D50139&action=3Dedit Proposed fix filesystem::rename must replace existing files and currently does so on most platforms by simply calling posix::rename. But on Windows (specifically Min= GW), 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-wre= name?view=3Dmsvc-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 ca= se for this. If someone could give me a hint which files to touch I could also work on that.=