https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90266
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- Which version are you using? (You didn't say) With trunk I get length_error thrown from the first push_back in f or g: terminate called after throwing an instance of 'std::length_error' what(): vector::_M_realloc_insert