2121. app for string streams

Section: [stringstream.cons] Status: NAD Submitter: Nicolai Josuttis Opened: 2012-01-15 Last modified: 2018-06-07 21:31:22 UTC

Priority: 3

View all issues with NAD status.


This issue was raised while discussing issue 1448.

Note the following program:

string s("s1: 123456789");
ostringstream s1(s, ios_base::out|ios_base::app);
s1 << "hello";
cout << s1.str() << endl;

With g++4.x it prints:

s1: 123456789hello

With VisualC++10 it prints:


From my intuitive understanding the flag "app" should result in the output of g++4.x. I also would read that from [ios::openmode] claiming:

app   seek to end before each write

However in issue 1448 P.J.Plauger comments:

I think we should say nothing special about app at construction time (thus leaving the write pointer at the beginning of the buffer). Leave implementers wiggle room to ensure subsequent append writes as they see fit, but don't change existing rules for initial seek position.

Note that the flag ate on both platforms appends "hello" to s.

[2018-06; Rapperswil Wednesday evening]

MC: shouldn't this be Open?
BO: I think we changed it to do the same thing as gcc
JM: NAD - gcc is right
ACTION close as NAD, noting that gcc is right

Proposed resolution: