This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: defect in STL string
Thank you Martin for your timely and thorough response.
I now understand why there is a difference. g++ has a
different behavior in strstream than the older HP compiler
we're using.
Cheryl
>> 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
>
>
>