https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108645
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Jonathan Wakely from comment #3) > In your example, all your strings fit in the SSO buffer inside the > std::string object, so the LHS has sufficient capacity for the result. Actually that's only true until the last step of the algorithm. On the last step (when appending "example" to "this_is_an_") neither the LHS nor the RHS has capacity for the result, so a reallocation is needed. But it's true that the RHS has nothing to steal at any step in the algorithm, so we append to the LHS and let that reallocate itself if needed. > And > there's nothing to steal from the RHS anyway, as it doesn't own any > allocated memory.