[Bug libstdc++/25719] ostringstream::str().c_str() returns pointer to unallocated memory
pcarlini at suse dot de
gcc-bugzilla@gcc.gnu.org
Mon Jan 9 10:26:00 GMT 2006
------- Comment #2 from pcarlini at suse dot de 2006-01-09 10:26 -------
The problem in your code, which makes it illegal, in general, is not c_str(),
which indeed is used correctly, but str(): it generates a temporary (note that
it returns by **value**, e.g., doesn't return a reference to a string object
inside the stream), which dies, correctly, before printit is called. There are
many ways to deal with the issue, perhaps you can first assign the string
returned by str() to a local string.
--
pcarlini at suse dot de changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25719
More information about the Gcc-bugs
mailing list