This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
defect in STL string
- To: bug-gcc at gnu dot org
- Subject: defect in STL string
- From: cheryl <cheryl at col dot hp dot com>
- Date: Fri, 18 Feb 2000 13:16:28 -0700
- Cc: cheryl at col dot hp dot com
I found a possible defect in the STL <string> template.
gcc version 2.95.2
running on HP-UX 10.2
>g++ -o tstring tstring.cxx
>tstring
stream: one two three
s3 != 'three'
s3: 'three'
s3.length(): '6'
The problem is the length of the string s3 is really 5
not 6 so the comparison fails. I've never submitted a
gnu bug so I'm not sure what the procedure is for finding
out the status of this bug. Any info you could give me
would be greatly appreciated.
Cheryl Brown
Agilent Technologies
--------- tstring.cxx -------------
#include <strstream.h>
#include <string>
int main()
{
string s1 = string();
string s2 = "one two";
string s3 = " three";
strstream stream;
stream << s1 << s2 << s3 << ends;
cout << "stream: " << stream.str() << "\n";
stream >> s1 >> s2 >> s3;
if (s1 != "one") cout << "s1 != 'one'\n"; // succeeds
if (s2 != "two") cout << "s2 != 'two'\n"; // succeeds
if (s3 != "three") cout << "s3 != 'three'\n"; // fails
cout << "s3: '" << s3 << "'\n";
cout << "s3.length(): '" << s3.length() << "'\n";
}