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

            Bug ID: 64936
           Summary: regex, ECMA treated as posix
           Product: gcc
           Version: 4.9.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pierreblavy at yahoo dot fr

Hi!

I've tested gcc regex with the following code (seen on
http://en.cppreference.com/w/cpp/regex/syntax_option_type). According to this
website, I expect ECMA to match zzxa, and not zzxayy. I don't know if it's gcc
or cppreference.com that's wrong.


--- test code ---
int main()
{
    std::string str = "zzxayyzz";
    std::regex re1(".*(a|xayy)"); // ECMA
    std::regex re2(".*(a|xayy)", std::regex::extended); // POSIX

    std::cout << "Searching for .*(a|xayy) in zzxayyzz:\n";
    std::smatch m;
    std::regex_search(str, m, re1);
    std::cout << " ECMA (depth first search) match: " << m[0] << '\n'; //expect
zzxa, have zzxayy ==> WRONG
    std::regex_search(str, m, re2);
    std::cout << " POSIX (leftmost longest)  match: " << m[0] << '\n'; //expect
zzxayy, have zzxayy ==> OK
}

Reply via email to