From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 455833858C39; Thu, 24 Aug 2023 11:37:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 455833858C39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1692877072; bh=OgdbfhL20EestEtwwFvrQrmuWeklODxC9FTmkCKjwM8=; h=From:To:Subject:Date:From; b=ioR5WnXNGorVT61QbnbuE72XRetVNKfkIIRIn4Erko51Molo4uc+MwNlxhuyuHZiV kkjsnXHvzVeojDa7ug0vVC0pMg22y+/aOneYGamG3TeKeOnoxHqI20fv5mAYJAxPAJ qFtHd6byRM2CI38ySJJGbYs7tDQZpSGXbsNduYhs= From: "gcc at octaforge dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/111129] New: std::regex incorrectly matches quantifiers with plus appended Date: Thu, 24 Aug 2023 11:37:51 +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: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: gcc at octaforge dot org 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D111129 Bug ID: 111129 Summary: std::regex incorrectly matches quantifiers with plus appended Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: gcc at octaforge dot org Target Milestone: --- Example code: ``` #include #include #include int main(void) { std::smatch matches; auto re =3D std::regex(R"(a++)", std::regex::icase); std::string inp =3D "aaa"; std::regex_search(inp, matches, re); for (auto &match: matches) { printf("%s\n", match.str().data()); } } ``` With libstdc++, this does not crash, and outputs 'aaa'. This gives people a false idea that libstdc++ implements possessive quantif= iers (see e.g. https://github.com/wwmm/easyeffects/pull/2536) despite the documentation or code having no references to any such extension (and the C= ++ standard likewise not mentioning it). You can verify that the semantics are= not possessive by changing the pattern to 'a++a', which should with possessive semantics not match anything, but with libstdc++ it's an identical match as before. With libc++, this correctly fails with: libc++abi: terminating due to uncau= ght exception of type std::__1::regex_error: One of *?+{ was not preceded by a valid regular expression.=