https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110190

            Bug ID: 110190
           Summary: regex: incorrect match results on DFA engines
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mimomorin at gmail dot com
  Target Milestone: ---

libstdc++ makes incorrect matches with the sample code in
https://en.cppreference.com/w/cpp/regex/syntax_option_type . (Though the
description of the "leftmost longest rule" is not correct in that page, their
expected results are fine).

Here is a slightly shorter version:
    #include <iostream>
    #include <string>
    #include <regex>

    int main()
    {
        std::string text = "regexp";
        std::regex re(".*(ex|gexp)", std::regex::extended);
        std::smatch m;
        std::regex_search(text, m, re);
        std::cout << m[0] << '\n'; // => should be "regexp" on DFA engines
    }
This should print "regexp", but libstdc++ prints "regex". (libc++ works fine.)

Reply via email to