Bug 49870 - regex_match vs. "^"
Summary: regex_match vs. "^"
Status: RESOLVED DUPLICATE of bug 53631
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-27 16:13 UTC by Benjamin Kosnik
Modified: 2012-06-11 08:36 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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 ***