c++/5298: stream::write

Loren James Rittle rittle@latour.rsch.comm.mot.com
Tue Jan 8 19:43:00 GMT 2002


In article <Pine.LNX.4.30.0201080942370.3907-100000@narwhal.ca.metsci.com>
you write:

> This solved the symptom I described but there is still some funkiness
> going on.  Now, I know what I am describing here is not well defined
> behavior but if take the following program an run it, it always gives
> the same output (up to the order of the lines).  That is, every line is
> printed correctly, but they may come in different orders.  However, if
> you redirect the output to a file, sometimes the output of lines gets
> merged.  I never noted this behavior on the 2.96 compiler...

You hit the nail on the head when you said: ``not well defined
behavior''.  You have hit an area of the C++ standard that makes no
guarantees as you expect.

The libstdc++ shipped with 2.96 shares little or no code with the one
shipped with 3.0.X.  The merging issue you report has been seen but
deemed allowed by the C++ standard.  If you want to ensure that lines
of output are consistent, then you must provide some sort of locking
mechanism at the application code level.

Regards,
Loren
-- 
Loren J. Rittle
Senior Staff Software Engineer, Distributed Object Technology Lab
Networks and Infrastructure Research Lab (IL02/2240), Motorola Labs
rittle@rsch.comm.mot.com, KeyID: 2048/ADCE34A5, FDC0292446937F2A240BC07D42763672



More information about the Gcc-bugs mailing list