This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
simple bastring bug [egcs-1.03a (2.90.29)]
- To: egcs-bugs at cygnus dot com
- Subject: simple bastring bug [egcs-1.03a (2.90.29)]
- From: Andrew Mauer-Oats <mauer at math dot uiuc dot edu>
- Date: Wed, 22 Jul 1998 16:59:28 -0500
- Reply-To: mauer at uiuc dot edu
It appears that appending a character string to a "string" does not
give a null-terminated string. The appended test program shows this.
I do not think this should be the behaviour. To copy the terminating
null, one should use traits::length(s)+1 when appending/replacing.
Andrew Mauer-Oats
mauer@uiuc.edu
========================================================================
#include <iostream.h>
#include <string>
int main (void)
{
string x("ThisEndlessTrialOppressesMe");
const char *frob = "/file-------";
cout << x << endl;
x = "/opt";
cout << x << endl;
x += frob;
cout << x << endl;
printf("As a string, x = %s\n",x.data());
return 0;
}
========================================================================
ThisEndlessTrialOppressesMe
/opt
/opt/file-------
As a string, x = /opt/file-------OppressesMe
========================================================================