https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86164
Bug ID: 86164 Summary: std::regex crashes when matching long lines Product: gcc Version: 7.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: holger.seelig at yahoo dot de Target Milestone: --- std::regex crashes when matching long lines. Here is an example: #include <regex> #include <iostream> int main() { std::string s (100'000, '*'); std::smatch m; std::regex r ("^(.*?)$"); std::regex_search (s, m, r); std::cout << s .substr (0, 10) << std::endl; std::cout << m .str (1) .substr (0, 10) << std::endl; } It turns out that std::regex_search operator .* is implemented recursively which result in this example in a stack overflow.