From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 897873838006; Tue, 24 May 2022 15:29:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 897873838006 From: "andij.cr at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/105720] New: std::views::split_view wrong behaviour in case of partial match Date: Tue, 24 May 2022 15:29:58 +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.3.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: andij.cr at gmail dot com 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: Tue, 24 May 2022 15:29:58 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105720 Bug ID: 105720 Summary: std::views::split_view wrong behaviour in case of partial match Product: gcc Version: 10.3.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: andij.cr at gmail dot com Target Milestone: --- compiled with=20 g++-10 -std=3Dc++20 split_view_wrong.cpp -lfmt godbolt link https://gcc.godbolt.org/z/47TxWovd4 fmtlib used for exposition only #include #include #include #include auto words_no_bug =3D std::string_view{"Hello-_-C++-_-20-_-!-_-"}; auto words_bug =3D std::string_view{"Hello--_-C++-_-20-_-!-_-"}; auto delim =3D std::string_view{"-_-"}; // needed because split_view is lazy in gcc 10.3 auto range_to_str =3D [](auto &&r) { return fmt::format("{}", fmt::join(r, "")); }; int main() { fmt::print("no bug: '{}' tokens: {}\n", words_no_bug, words_no_bug | std::views::split(delim) | std::views::transform(range_to_str)); fmt::print("bug: '{}' tokens: {}\n", words_bug, words_bug | std::views::split(delim) | std::views::transform(range_to_str)); } this code applies split to tokenize a text compiled with gcc-10.3 it wrongly produces no bug: 'Hello-_-C++-_-20-_-!-_-' tokens: ["Hello", "C++", "20", "!"] bug: 'Hello--_-C++-_-20-_-!-_-' tokens: ["Hello-", "20", "!"] while compiled with gcc-11.3 is correctly produces=20 no bug: 'Hello-_-C++-_-20-_-!-_-' tokens: ["Hello", "C++", "20", "!"] bug: 'Hello--_-C++-_-20-_-!-_-' tokens: ["Hello-", "C++", "20", "!"] notice how the substring "--_-C++" instead of being split in ["-", "C++"] is split as ["-"], skipping the "C++" token. it's fixed from gcc-11, but i couldn't find a mention in the release notes about it=