https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81338
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |redi at gcc dot gnu.org --- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- The problem is that basic_stringbuf::overflow assumes that if pptr() == epptr() then we need to reallocate. After a move we might have pptr() == epptr() but also have unused capacity in the string. We should move epptr() to use that capacity, instead we reallocate to double the string's capacity, which keeps trying to allocate bigger and bigger buffers until allocation fails.