https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102447
Bug ID: 102447 Summary: std::regex incorrectly accepts invalid bracket expression Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org Blocks: 102445 Target Milestone: --- #include <regex> #include <cassert> int main() { try { std::regex{"[\\w-a]"}; assert(!"here"); } catch (const std::regex_error& e) { assert(e.code() == std::regex_constants::error_range); } } This should run and exit successfully, but with GCC we get: a.out: reg.C:8: int main(): Assertion `!"here"' failed. Aborted (core dumped) The bracket expression [\w-a] is invalid. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102445 [Bug 102445] [meta-bug] std::regex issues