public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/57273] New: stringstream str initialization fails
@ 2013-05-14 12:41 ycollette.nospam at free dot fr
  2013-05-14 12:42 ` [Bug libstdc++/57273] " ycollette.nospam at free dot fr
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: ycollette.nospam at free dot fr @ 2013-05-14 12:41 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57273

            Bug ID: 57273
           Summary: stringstream str initialization fails
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ycollette.nospam at free dot fr

It tried to initialize the content of a stringstream using the following code:

std::stringstream tmpLabel;

tmpLabel.str("test ");
tmpLabel << 1;

And the result fails. I've got on screen: '1est' instead of 'test 1'.

The workaround:

std::stringstream tmpLabel;

tmpLabel.str("");
tmpLabel << "test " << 1;

Here is a test file:

#include <iostream>
#include <sstream>

int main()
{
        std::stringstream tmp;

        tmp.str("test\0");

        tmp << 1;

        std::cout << "result = |" << tmp.str() << "|" << std::endl;

        tmp.str("");

        tmp << "test " << 1;

        std::cout << "result = |" << tmp.str() << "|" << std::endl;

        return 0;
}


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-05-14 13:05 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-14 12:41 [Bug libstdc++/57273] New: stringstream str initialization fails ycollette.nospam at free dot fr
2013-05-14 12:42 ` [Bug libstdc++/57273] " ycollette.nospam at free dot fr
2013-05-14 12:43 ` ycollette.nospam at free dot fr
2013-05-14 12:47 ` paolo.carlini at oracle dot com
2013-05-14 12:55 ` ycollette.nospam at free dot fr
2013-05-14 12:59 ` redi at gcc dot gnu.org
2013-05-14 13:01 ` redi at gcc dot gnu.org
2013-05-14 13:05 ` ycollette.nospam at free dot fr

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).