[Bug c++/86165] New: std::regex crashes when matching long lines.
holger.seelig at yahoo dot de
gcc-bugzilla@gcc.gnu.org
Fri Jun 15 10:49:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86165
Bug ID: 86165
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.
More information about the Gcc-bugs
mailing list