Bug 49870

Summary: regex_match vs. "^"
Product: gcc Reporter: Benjamin Kosnik <bkoz>
Component: libstdc++Assignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED DUPLICATE    
Severity: normal CC: tim
Priority: P3    
Version: 4.6.0   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed:

Description Benjamin Kosnik 2011-07-27 16:13:16 UTC
The following valid program using c++0x's regex fails, but works with C regex utilities and the boost version of these components:

-------

#include <regex>
#include <cstdio>

// compile like
// g++ -std=gnu++0x -g -O2 71871-regex.cpp  -Wfatal-errors

// execute like
// ./a.out "foo.*" "foobar"   == OK
// ./a.out "^foo.*" "foobar"  == FAIL
int
main(int argc, char **argv)
{
     std::regex expr(argv[1], std::regex_constants::extended);
    std::string test_string = argv[2];
    printf("Applying regex '%s' to string '%s'\n", argv[1], argv[2]);
    
    if (std::regex_match(test_string, expr)) 
      printf("C++: Match\n");
    else 
      printf("C++: NO match\n");
  
return 0;
}


---
This is originally reported in RH Bugzilla as 
https://bugzilla.redhat.com/show_bug.cgi?id=718711
Comment 1 Jonathan Wakely 2011-07-30 11:38:01 UTC
See PR 47724
Comment 2 Jonathan Wakely 2012-06-11 08:36:51 UTC
.

*** This bug has been marked as a duplicate of bug 53631 ***