This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/81338] stringstream remains empty after being moved into multiple times
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 06 Jul 2017 15:00:25 +0000
- Subject: [Bug libstdc++/81338] stringstream remains empty after being moved into multiple times
- Auto-submitted: auto-generated
- References: <bug-81338-4@http.gcc.gnu.org/bugzilla/>
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.