Sender: dscott AT chernikeeff DOT co DOT uk Message-Id: <3649ECBC.794BDF32@chernikeeff.co.uk> Date: Wed, 11 Nov 1998 19:59:56 +0000 From: Doug Scott X-Mailer: Mozilla 3.01 (X11; I; SunOS 4.1.3 sun4m) Mime-Version: 1.0 To: djgpp AT delorie DOT com Subject: gcc v281 bug? Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp AT delorie DOT com Hi, I am not a compiler wizard but I think that I have found a bug in djgpp. Versions: bnu281b djdev201 gcc281b operating system NT 4.0 SP3 The Code: #include main( int argc, char* argv[] ) { printf( "aaa" ) ; putch( 'Q' ) ; /* goes to screen not stdout */ printf ( "zzz") ; } Compiled with: gcc test1.c -o test1.exe -lm The output is: Qaaazzz I would expect the output to be: aaaQzzz Other notes: If the program is run with test1 > out The character Q goes to the screen and the rest to the file. I cannot recall if putch() is "supposed to" use stdout or not and I have mentioned this here just in case it is. I also tried outputting many (1000) Q's with a for loop and the order was the same. That is Q's first. Code fragment for this: printf( "aaa" ) ; for ( i=0 ; i<1000 ; i++ ) putch( 'Q' ) ; /* goes to screen not stdout */ printf ( "zzz") ; This latter test result suggests to me that the problem may be due to some code re-ordering due to optimisation, and not as I at first considered due to NT returning from printf() before the output was actually put on the display and putch() taking a shortcut and getting there first. I do not read the mail list but it would be nice to know if the bug is in my analysis or in the compiler/library. Douglas.