This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: defect in STL string
- To: cheryl at col dot hp dot com
- Subject: Re: defect in STL string
- From: "Martin v. Loewis" <martin at loewis dot home dot cs dot tu-berlin dot de>
- Date: Sat, 19 Feb 2000 18:44:18 +0100
- CC: bug-gcc at gnu dot org, cheryl at col dot hp dot com
- References: <3.0.1.32.20000218131628.01025140@cheryl.col.hp.com>
> 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;
- endoffile 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