ahatanak added a comment. My understanding is that typically std::ends is explicitly appended to null-terminate the stream buffer. The test case in the example does that. http://en.cppreference.com/w/cpp/io/ostrstream/str http://reviews.llvm.org/D20334