This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Change of behaviour, or something broke in cin/streambuf behaviourbetween 3.3.4 and 3.4.1?


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 ;)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]