https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116903
Bug ID: 116903 Summary: c++ regex accepts } and ] as a literal character. Product: gcc Version: 14.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: fsb4000 at yandex dot ru Target Milestone: --- I'm not sure if this is your extension or a bug, but I found that libstdc++ accepts '}' and ']' in regex. MS STL and libc++ throw an exception for these examples and libstdc++ prints "it's legal". Code: // https://godbolt.org/z/EqejrjqGP #include <regex> int main() { try { std::regex r("a{0}]"); puts("it's legal"); } catch (std::exception& e) { puts(e.what()); } } and // https://godbolt.org/z/Ec4nMc9js #include <regex> int main() { try { std::regex r("a{0}}"); puts("it's legal"); } catch (std::exception& e) { puts(e.what()); } }