https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80498
Bug ID: 80498 Summary: Simple program with address sanitizer and regex hangs Product: gcc Version: 6.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: sanitizer Assignee: unassigned at gcc dot gnu.org Reporter: gcc at zutt dot org CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org, jakub at gcc dot gnu.org, kcc at gcc dot gnu.org Target Milestone: --- If I compile the below two files with "g++-6 -fsanitize=address a.cpp m.cpp" and then run "./a.out", the program hangs forever, while without sanitize flag it works as expected. If I comment out the regex var 're' in m.cpp, the problem also disappears. Is there some incompatibility with the regex library, and can that be solved or can the library be excluded from checks? I'm on macOS Sierra version 10.12.4 with g++-6 (Homebrew GCC 6.3.0_1) 6.3.0. Thanks! === #include <iostream> #include <regex> #include <string> using namespace std; void a(const std::string &s) { regex re_a("foo (.+)"); smatch pieces; if (regex_match(s, pieces, re_a)) { cout << "foo with " << pieces[1].str() << endl; } } // m.cpp #include <string> #include <regex> void a(const std::string &s); int main(int argc, char** argv) { std::regex re("123"); a("foo test 123"); }