This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Change of behaviour, or something broke in cin/streambuf behaviourbetween 3.3.4 and 3.4.1?
- From: Paolo Carlini <pcarlini at suse dot de>
- To: Andrew Walrond <andrew at walrond dot org>
- Cc: gcc at gcc dot gnu dot org
- Date: Wed, 22 Sep 2004 11:59:21 +0200
- Subject: Re: Change of behaviour, or something broke in cin/streambuf behaviourbetween 3.3.4 and 3.4.1?
- References: <200409221038.31663.andrew@walrond.org>
Andrew Walrond wrote:
When compiled with gcc 3.3.4 produces
in_avail 6
but when compiled with gcc 3.4.1 produces
in_avail 0
Is the code using some undefined behaviour, or did something break?
In my opinion, the current behavior is correct. Indeed, something changed
but didn't 'break' ;) (*) Basically, the reason is that in 3.4.x we have
a new
unbuffered filebuf for cin, cout & co, which *improves* considerably the
correctness of the library in its interactions with stdio. This streambuf is
used, correctly, by default.
In order to get the old behavior, you can add
std::ios::sync_with_stdio(false)
at the beginning of your program, which changes cin, cout & co to use the
buffered filebuf (the only one available in 3.3.x).
Paolo.
(*) FWIW, Icc8 agrees ;)