This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/20114] New: Non-monotonic behavior of string::reserve
- From: "kreckel at ginac dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 20 Feb 2005 21:41:30 -0000
- Subject: [Bug libstdc++/20114] New: Non-monotonic behavior of string::reserve
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
gromit:/tmp$ cat resize.cc
#include <iostream>
#include <string>
using namespace std;
int main()
{
string line;
for ( size_t c=8162; c<8166; ++c ) {
line.reserve(c);
cout << line.capacity() << endl;
}
}
gromit:/tmp$ g++-3.4 -v
Lese Spezifikationen von /usr/lib/gcc/i486-linux/3.4.4/specs
Konfiguriert mit: ../src/configure -v
--enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr
--libexecdir=/usr/lib --with-gxx-include-dir=/usr/include/c++/3.4
--enable-shared --with-system-zlib --enable-nls --without-included-gettext
--program-suffix=-3.4 --enable-__cxa_atexit --enable-libstdcxx-allocator=mt
--enable-clocale=gnu --enable-libstdcxx-debug --enable-java-gc=boehm
--enable-java-awt=gtk --disable-werror i486-linux
Thread-Modell: posix
gcc-Version 3.4.4 20041218 (prerelease) (Debian 3.4.3-6)
gromit:/tmp$ g++-3.4 resize.cc
gromit:/tmp$ ./a.out
8163
8163
16355
12259
Apparently, reserve/resize overallocate when called with 8164 as argument
(unless the string has been empty before). There are other such points, at
12260, 16356, 20452, 24548 and so on at each bump where a (monotonic) change in
size is intented.
--
Summary: Non-monotonic behavior of string::reserve
Product: gcc
Version: 3.4.4
Status: UNCONFIRMED
Severity: enhancement
Priority: P2
Component: libstdc++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: kreckel at ginac dot de
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i486-linux
GCC host triplet: i486-linux
GCC target triplet: i486-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20114