From: Brendan Simon Date: Thu, 17 Aug 1995 19:04:34 +1000 To: djgpp AT sun DOT soe DOT clarkson DOT edu Subject: optimization.bug I have some kind of wierd optimization bug in V2. When reading an I/O status port on my A2D card, the BUSY bit seems to get stuck on after the first read of this port. The code is :- short get_A2D(char channel) { channel = channel % 8; outportb(CONTROL_REG, channel); /** select A2D channel to convert **/ while( (inportb(STATUS_REG) & BUSY_BIT) ); /** wait for not busy **/ outportb(START_CONVERSION, 0xff); /** start A2D conversion **/ while( (inportb(STATUS_REG) & BUSY_BIT) ); /** wait for not busy **/ return( inportw(A2D_DATA) ); } With any of the optimizations selected, the 2nd while loop never terminates as the busy bit always appears high. With no optimization the code works as expected. Any ideas. Is it a bug or is it a silly mistake somewhere??? Brendan Simon brendan AT rdt DOT monash DOT edu DOT au