This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/32068] vector push_back()/resize() causes assignment to deleted memory
- From: "fang at csl dot cornell dot edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 24 May 2007 18:55:13 -0000
- Subject: [Bug libstdc++/32068] vector push_back()/resize() causes assignment to deleted memory
- References: <bug-32068-14512@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #2 from fang at csl dot cornell dot edu 2007-05-24 19:55 -------
Suggestion: determine some lower bound of the size (or exact) N prior to a
sequence of push_back()s, and call vector::reserve(N) in advance. Then as long
as the capacity isn't exceeded, you avoid any reallocation.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32068