http://llvm.org/bugs/show_bug.cgi?id=22021
Marshall Clow (home) <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |INVALID --- Comment #1 from Marshall Clow (home) <[email protected]> --- This is a "required" memory leak (if you can believe that). When you call strstreambuf::str() (which ostrstream is derived from), you get a pointer to its internal buffer, and the stream is "frozen" (see depr.strstreambuf.members/2 in the standard). Note that in spite of the method being named "str", it does NOT return a std::string. When the stream is destructed, the buffer may not be freed if the stream is "frozen". (see depr.strstreambuf.cons/8). If you rewrite your code thus: static std::string MessageComposer( uint32_t index ) { std::ostrstream stm; stm << "This is message #" << index << "." << std::endl; std::string foo = stm.str(); stm.freeze(false); return foo; } you will see that the "leak" has disappeared. (Yeah, it's easy to misuse this object. Maybe that's why it is deprecated) -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ LLVMbugs mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs
