https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112680
Bug ID: 112680 Summary: g++-13 segfault on std::regex_match with c++11 or above -O2 and lto Product: gcc Version: 13.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: costamagnagianfranco at yahoo dot it Target Milestone: --- Created attachment 56672 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56672&action=edit reproduce test case This used to work with g++-10 and started to fail with g++-11 g++-12 and g++-13 sh runme.sh Segmentation fault (core dumped) g++-12 main.cpp -std=c++11 -O2 -flto=auto -o main && ./main The main is really simple, load two strings, and call regex function #include <fstream> #include <sstream> #include <iostream> #include <regex> int main() { std::ifstream t("file.txt"); std::stringstream file; file << t.rdbuf(); std::string filestr = file.str(); std::ifstream t2("regex.txt"); std::stringstream filepathregex; filepathregex << t2.rdbuf(); std::string regexstr = filepathregex.str(); const std::regex regex(regexstr); std::regex_match(filestr.begin(), filestr.end(), regex); } I attached the tarball with the files to reproduce the issue. The content triggering the issue was originated by the testsuite dump of zim-tools https://launchpad.net/ubuntu/+source/zim-tools/3.2.0-1build1