https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117457
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> --- So from my reading the sanitizier output, it seems like a check for `_M_current == _M_end` is missing or is being optimized away incorrectly. I think the latter. 0x5621f46983b4 is located 0 bytes after global variable '*.LC29' defined in './a.ltrans1.ltrans' (0x5621f4698380) of size 52 '*.LC29' is ascii string '\/some\/http\/(\d{1,2})\/(\d{1,2})\/(\d{1,2})\/test' READ of size 1 at 0x5621f46983b4 thread T0 #0 0x5621f4658d06 in std::__detail::_Scanner<char>::_M_scan_normal() /usr/include/c++/14/bits/regex_scanner.tcc:98 #1 0x5621f4658d06 in std::__detail::_Scanner<char>::_M_advance() /usr/include/c++/14/bits/regex_scanner.tcc:79 And looking into _M_advance, there is a check before the call of _M_scan_normal even: if (_M_current == _M_end) { _M_token = _S_token_eof; return; } I have not looked into the produced code yet though.