public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: libstdc++/8636: ostringstreams lose their data
@ 2002-11-30 20:56 Paolo Carlini
  0 siblings, 0 replies; 2+ messages in thread
From: Paolo Carlini @ 2002-11-30 20:56 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR libstdc++/8636; it has been noted by GNATS.

From: Paolo Carlini <pcarlini@unitus.it>
To: gcc-gnats@gcc.gnu.org,  nobody@gcc.gnu.org
Cc:  
Subject: Re: libstdc++/8636: ostringstreams lose their data
Date: Thu, 21 Nov 2002 13:15:49 +0100

 Hello again,
 I think I found the reason for this, it's not a bug.
 
 If 'oss' is an ostringstream, then calling
 
    x = oss.str().c_str();
 
 is a bad idea, because oss.str() returns a copy of the contents of oss
 by value, i.e. a temporary value that is free'd right after this
 statement.  Therefore x is invalid, pointing to a free'd memory region.
 
 --> oss.str().c_str() will always return a pointer to a temporary
      value.
      For example, strcpy(dest, oss.str().c_str()) would work, but
      not   x=oss.str().c_str(); strcpy(dest,x);
 
 I believe this is ok with the standard.
 Sorry, my fault.
 
 Regards,
 Michael
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8636
 


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

* Re: libstdc++/8636: ostringstreams lose their data
@ 2002-11-30 20:06 paolo
  0 siblings, 0 replies; 2+ messages in thread
From: paolo @ 2002-11-30 20:06 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, michael.pronath, nobody

Old Synopsis: global ostringstreams lose their data
New Synopsis: ostringstreams lose their data

State-Changed-From-To: feedback->open
State-Changed-By: paolo
State-Changed-When: Thu Nov 21 03:08:31 2002
State-Changed-Why:
    Additional information received, synopsis updated.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8636


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

end of thread, other threads:[~2002-11-21 12:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-30 20:56 libstdc++/8636: ostringstreams lose their data Paolo Carlini
  -- strict thread matches above, loose matches on Subject: below --
2002-11-30 20:06 paolo

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).