https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85472
--- Comment #4 from Hans Ã…berg <haberg-1 at telia dot com> --- (In reply to Tim Shen from comment #1) > I know exactly how libc++ produces this result. It creates an empty > match_result during each repetition ("*" operator). It's less confusing but > much slower. I wrote an NFA/DFA that computes all matches, it seems, in an efficient manner: Action numbers are marked on the states of the sub-NFAs one is interested in. While lexing a string, the partial reverse NFA is recorded, which is searched when a final state is encountered. The string position action numbers, as marked on the corresponding states, are recorded, and for each action number, the contiguous string sequences are the possible submatches.