This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/23494] New: std::basic_string <> capacity weirdness
- From: "pogonyshev at gmx dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 20 Aug 2005 16:22:38 -0000
- Subject: [Bug libstdc++/23494] New: std::basic_string <> capacity weirdness
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Whether capacity of strings shrinks depends on whether the strings are shared.
I believe this also true for 4.0.1, but I only have the sources of it, didn't
compile.
To reproduce (note that `s2' is not shared at the time of push):
int
main()
{
string s1;
s1.reserve (10000);
string s2 = s1;
s1.push_back ('!');
s2.push_back ('!');
cout << "s1 capacity: " << s1.capacity () << endl;
cout << "s2 capacity: " << s2.capacity () << endl;
return 0;
}
Output (here):
s1 capacity: 1
s2 capacity: 12259
--
Summary: std::basic_string <> capacity weirdness
Product: gcc
Version: 3.2
Status: UNCONFIRMED
Severity: minor
Priority: P2
Component: libstdc++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: pogonyshev at gmx dot net
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23494