Change of behaviour, or something broke in cin/streambuf behaviour between 3.3.4 and 3.4.1?
Paolo Carlini
pcarlini@suse.de
Wed Sep 22 13:22:00 GMT 2004
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 ;)
More information about the Gcc
mailing list