From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A9D89383E831; Mon, 11 May 2020 07:59:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A9D89383E831 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1589183949; bh=BBUiRKghVHlA4utqHjZXHUSIYIZ+lzpN13NOOJZ6G9c=; h=From:To:Subject:Date:From; b=HlI6K0rqSjj7HFdvSeik5+TdpKhegsz6O1w94tDJgpK6OCCvHlJAQWnGySyOr2TvE hrJkwq0SD2d1PDVBvUP1cIGeVpEej7qeyRSnRdpRBNMyzMdPn0XrpJIfD2M3mLJeWP Ix8lJv/wnwCB9V6VqKxQ2A3/9wle5FgGsysHUln4= From: "kontakt at neonfoto dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/95048] New: wstring-constructor of std::filesystem::path throws for non-ASCII characters Date: Mon, 11 May 2020 07:59:09 +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.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: kontakt at neonfoto 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 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: Mon, 11 May 2020 07:59:09 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95048 Bug ID: 95048 Summary: wstring-constructor of std::filesystem::path throws for non-ASCII characters Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: kontakt at neonfoto dot de Target Milestone: --- When trying to port our Windows application to Linux, I encountered a probl= em constructing an instance of std::filesystem::path with a wide-character lit= eral containing a non-ASCII wchar: #include int main() { std::filesystem::path p =3D L"=C3=A4"; } This builds fine with g++-10 -Wall -Wextra -pedantic -std=3Dc++17 minimal.c= pp on my Ubuntu 18.04 in WSL (using g++ from this ppa: https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test) but throws = an exception on execution:=20 terminate called after throwing an instance of 'std::filesystem::__cxx11::filesystem_error' what(): filesystem error: Cannot convert character sequence: Invalid or incomplete multibyte or wide character Reading the C++ standard, I believe this should not happen and libstdc++ sh= ould be able to convert the wchar literal to a path. Using clang with libc++ ins= tead of libstdc++ performs a conversion as I expected. Trying different versions= of g++ in the Compiler Explorer (https://godbolt.org/z/KQD1I6) shows that this also used to work with g++9.1 and stopped working in g++9.2. The problem was already described by someone else in this StackOverflow pos= t: https://stackoverflow.com/questions/58521857/cross-platform-way-to-handle-s= tdstring-stdwstring-with-stdfilesystempath=