This is the mail archive of the libstdc++@sourceware.cygnus.com mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

bugreport:string again


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]