This is the mail archive of the
libstdc++@sourceware.cygnus.com
mailing list for the libstdc++ project.
bugreport:string again
- To: libstdc++_list <libstdc++@sourceware.cygnus.com>
- Subject: bugreport:string again
- From: Alfred Minarik <a8601248@unet.univie.ac.at>
- Date: Sat, 29 May 1999 17:00:15 +0200
I could not resist again reporting you a bug with strings:
[Linux pc 2.2.5, egcs ss19990524, libstdc++v3 cvs19990521(and later)]
This small program gets a Segmentation fault:
--------------
using namespace std;
#include <string>
int main()
{
string t="part1_"+string("part2_")+"and a long part3.";
}
--------------
or if you prefer one with erroneous output:
--------------
using namespace std;
#include <cstdio>
#include <string>
int main()
{
string z="Take part1 ";
z+="another longer part2 ";
z+="and this";
printf("%d:%s\n",z.length(),z.c_str());
}
--------------
this should print
40:Take part1 another longer part2 and this
but prints
40:Take part1 another longe9
I tried to take a closer look but got confused with all
those allocations, but it's not only me,
it seem also libstdc++v3 looses track of them ...
Alfred