defect in STL string
Martin v. Loewis
martin@loewis.home.cs.tu-berlin.de
Sat Feb 19 09:47:00 GMT 2000
> I found a possible defect in the STL <string> template.
Thanks for your bug report. I believe the bug is in your code, and not
in gcc. When inserting std::ends into the strstream, a null byte is
appended to the stream.
When extracting a std::string from a stream, extraction shall continue
until one of the following conditions occur:
- n characters are stored;
- endÃÂofÃÂfile occurs on the input sequence;
- isspace(c,getloc()) is true for the next available input character
c.
(See 21.3.7.9/1 for the exact wording; n is either is.width() or
str.max_size())
Since isspace('\0') is false, the zero character is appended to s3,
giving a total length of six characters for s3. Since the null
character is not printing, you won't see it in the output.
Hope this helps,
Martin
More information about the Gcc-bugs
mailing list