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

            Bug ID: 68032
           Summary: std-c++-14: Regex fails to match
           Product: gcc
           Version: 5.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ge...@schorsch-tech.de
  Target Milestone: ---

I try to parse some data files and check the data with regex. During the parse
it fails on some lines. I reduced the code to the following.

<code>
#include <regex>
#include <iostream>
#include <string>
int main(int argc, char** argv)
{
        std::string data = " data(C96) = { 96, 1000, 15000, 6400, 6470, 0, 0,
7490, 8000, 1000, 1, 10, 0 };";
        auto ex0 = std::regex("data\\(([a-zA-Z0-9_-]+)\\) ?= ?\\{ ?([0-9+]),
?([0-9]+), ?([0-9]+), ?([0-9]+), ?([0-9]+), ?([0-9]+), ?([0-9]+), ?([0-9]+),
?([0-9]+), ?([0-9]+), ?([0-9]+), ?([0-9]+), ?([0-9]+) ?\\};");
        std::smatch what;

        if (std::regex_search(data, what, ex0))
        {
                std::cout << "Matched" << std::endl;
        }
        else
        {
                std::cout << "FAIL" << std::endl;
        }
}
</code>

Compile it with
g++ --std=c++14 main.cpp -o test

run it:
./test

Result:
FAIL:

Expected:
Matched

g++ --version
g++ (Gentoo 5.2.0 p1.2, pie-0.6.4) 5.2.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Reply via email to