From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 50E2C3885C3E; Wed, 11 Mar 2020 12:06:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 50E2C3885C3E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1583928370; bh=/te/111DDHN3iKxi4gP6gHpBOzeWxggY2tqMWaz6PEo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ToVfeNKxlsb5kA4M22Nd2abipGL3i0OgJLqpfBdcVuBi7Dt3CYtDbYogY4FGwQWfx KVynvv+f3xBtEtyoK2yXPRTIeX1gcxvbUEUwV2AHV2Z88DKiZGWVOcfW0Tc1vW3tIj k0v9e9wEMJXjfufHBPEa0NzkfL/Z0uj6qe0wd6Yo= From: "marxin at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/94063] filesystem::path concatenation doesn't work for Windows root-paths Date: Wed, 11 Mar 2020 12:06:10 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 10.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: marxin at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: redi at gcc dot gnu.org X-Bugzilla-Target-Milestone: 9.4 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: 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: Wed, 11 Mar 2020 12:06:10 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94063 Martin Li=C5=A1ka changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |marxin at gcc dot gnu.org --- Comment #4 from Martin Li=C5=A1ka --- commit r10-7095-gea182fe63634bb5b7913b3f1b6846e1900c5e0c4 Author: Jonathan Wakely Date: Mon Mar 9 23:22:57 2020 +0000 libstdc++: Handle type-changing path concatenations (PR 94063) The filesystem::path::operator+=3D and filesystem::path::concat functio= ns operate directly on the native format of the path and so can cause a path to mutate to a completely different type. For Windows combining a filename "x" with a filename ":" produces a root-name "x:". Similarly, a Cygwin root-directory "/" combined with a root-directory and filename "/x" produces a root-name "//x". Before this patch the implemenation didn't support those kind of mutations, assuming that concatenating two filenames would always produce a filename and concatenating with a root-dir would still have a root-dir. This patch fixes it simply by checking for the problem cases and creating a new path by re-parsing the result of the string concatenation. This is slightly suboptimal because the argument has already been parsed if it's a path, but more importantly it doesn't reuse any excess capacity that the path object being modified might already have allocated. That can be fixed later though. PR libstdc++/94063 * src/c++17/fs_path.cc (path::operator+=3D(const path&)): Add k= luge to handle concatenations that change the type of the first compone= nt. (path::operator+=3D(basic_string_view)): Likewise. * testsuite/27_io/filesystem/path/concat/94063.cc: New test.=