https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81476
--- Comment #11 from Marc Glisse <glisse at gcc dot gnu.org> --- Or one could (not legal) directly start a new allocation, copy the beginning of the vector, append the range, then append the end of the vector. Or a combination of all that: first try appending the range to the vector. If that works without reallocating, rotate. If a reallocation is necessary, switch to the "new allocation" strategy, create a new vector, copy the beginning of the vector, copy what we already inserted at the end, append the rest of the inputrange, copy the rest of the original vector, and finally adopt this new vector.