https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106607
Bug ID: 106607 Summary: Regex integer overflow on large backreference value Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: fsb4000 at yandex dot ru Target Milestone: --- Hello! I was fixing some MS STL issues with regex: GH-2168: integer overflow on large backreference value and I added a test. After that I decided to try my test with LLVM libc++ and GNU libstdc++. LLVM libc++ passes my test. and libstdc++ doesn't pass it. ``` #include <cassert> #include <regex> using namespace std; // GH-2168 <regex>: integer overflow on large backreference value int main() { try { // 4294967297 = 1 mod 2^32, so this will succeed if we don't check for overflow. regex testRegex{R"((a)\4294967297)", regex_constants::ECMAScript}; assert(false); } catch (const regex_error& e) { assert(e.code() == regex_constants::error_backref); } } ``` https://gcc.godbolt.org/z/nzET6nvxo