https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88947
--- Comment #5 from Tim Shen <timshen at gcc dot gnu.org> --- (In reply to Tomalak Geret'kal from comment #4) > To be honest I'd expect this in less trivial circumstances too. If, at a > given stage of processing, the only possible paths towards a match all > require a prefix that's already been ruled out, that should be an immediate > return false. To the best of my knowledge this is commonly what happens in > regex engines (though again libstdc++ is far from alone in the C++ world in > not doing so!) For the original test case, have you tried regex_match() with "what.*"? Do you have any non-trivial testcase in mind that is still unexpectedly slow with regex_match()?