This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/25719] New: ostringstream::str().c_str() returns pointer to unallocated memory


The 'c_str()' method of the STL 'basic_string' class template
returns a pointer to free memory when called against a
string returned by the 'str()' method of the 'basic_ostringstream'
class template.  ISO/IEC 14882 [21.3.6] indicates pointers returned
by 'c_str()' should be good until the next non-const member of the
string object is called.

This behavior is confirmed by both 'purify' and 'mudflap'.
The same test case runs clean with 'purify' on Solaris 8
with the Sun Studio 5.4 compiler.


-- 
           Summary: ostringstream::str().c_str() returns pointer to
                    unallocated memory
           Product: gcc
           Version: 4.0.1
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: lawless at spamcop dot net
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]