This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/81338] stringstream remains empty after being moved into multiple times


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]