https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61582
--- Comment #9 from Tim Shen <timshen at gcc dot gnu.org> --- (In reply to Maksymilian Arciemowicz from comment #8) > (In reply to Tim Shen from comment #7) > > "(.*{100}{100}{100})" seems to be a stack overflow. It's because regex > > executor uses recursion. It could be fixed (not segfault but memory > > exhaustion) by using a std::stack and simulate recursion; IMH, however, > > directly throwing regex_error::error_space is the right thing here to do. > > Yeap it's stack overflow. Why regex_error::error_space? Not better > regex_error::error_stack? Sorry for not clarify that: I prefer throwing error_space when constructing (complaining about too many states) instead of throwing error_stack when matching. To solve the latter problem, as I said, we can use a std::stack or something to avoid a stack overflow.