This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/61425] New: std::regex ignores backslash when using basic or grep grammars
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 05 Jun 2014 20:22:31 +0000
- Subject: [Bug libstdc++/61425] New: std::regex ignores backslash when using basic or grep grammars
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61425
Bug ID: 61425
Summary: std::regex ignores backslash when using basic or grep
grammars
Product: gcc
Version: 4.9.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
CC: timshen at gcc dot gnu.org
#include <regex>
#include <iostream>
using namespace std;
int main()
{
regex_constants::syntax_option_type grammar[] = {
regex_constants::basic, regex_constants::grep
};
for (auto g : grammar)
{
regex re("a\\|b", g);
const char str[] = "a|b";
cmatch m;
if (regex_search(str, m, re))
cout << m.size() << ' ' << m[0] << endl;
}
}
There should be two matches, "a" and "b", instead there's only one:
1 a|b
1 a|b
The backslash seems to be ignored.