This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/6896] ofstream, ^D and flushing
- From: "jlquinn at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 20 Jun 2003 05:27:19 -0000
- Subject: [Bug libstdc++/6896] ofstream, ^D and flushing
- References: <20020601130601.6896.schmid@snake.iap.physik.tu-darmstadt.de>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=6896
jlquinn at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |INVALID
------- Additional Comments From jlquinn at gcc dot gnu dot org 2003-06-20 05:27 -------
The output from 3.1.1 is correct.
Starting from output of "Enter line 1 of 3:", this is output to cout.
Next, cin.getline() is called. This calls istream::sentry, which flushes cout.
cin.getline() reads a ^D, which sets eof. It also sets failbit, since no input
was read.
Now, a newline is written and flushed to output (buff is empty).
Next, cerr << "cin state:" ... is written and flushed by the endl. Note that no
newline has been output. The second cerr output then happens.
Next is cout << "Enter line 2 of 3:". There is no endl to flush, so the output
accumulates in stdout's buffer.
The second cin.getline() does nothing because the sentry quits due to good() not
being true.
As above, a newline is written to output and flushed, and two lines are written
to cerr and flushed.
The third cin.getline() does nothing like the second one. And again, this is
followed by a newline being written to output and flushed, and two lines written
to cerr and flushed.
Finally, as the program terminates, cout is flushed, and we see the second and
third "Enter line x of 3:".