https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82513
Bug ID: 82513
Summary: regex [z\-a] fails to compile
Product: gcc
Version: 5.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: gene at genethomas dot com
Target Milestone: ---
The regex [z\-a] fails to compile in <regex> and throws a regex_error. It seems
to be interpreting the \- as a - and thinking the z-a range is invalid. Sample
program below:
#include <regex>
#include <iostream>
#include <exception>
using namespace std;
int main(int argc, char **argv) {
try {
regex::flag_type flags = regex::ECMAScript;
regex theRegex("[z\\-a]", flags);
cout << "ok\n";
return 0;
} catch (exception &e) {
cerr << "fatal error: " << e.what() << "\n";
return 1;
}
}