Message-ID: <32F1A438.5509@rangenet.com> Date: Fri, 31 Jan 1997 01:50:16 -0600 From: Dan Hedlund Reply-To: markiv AT rangenet DOT com Organization: Range Net MIME-Version: 1.0 To: djgpp AT delorie DOT com Subject: Possible bug/misfeature in GCC Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit The following lines compile wrong with the -O3 option. unsigned char inportb (int port) { unsigned char c; asm ("inb %%dx, %%al" : "=a" (c) : "d" (port)); return c; } void main (void) { while (inportb (0)); } GCC reads a byte from port 0 only once, and then compars that byte to 0 in an endless loop. Apparently GCC thinks the byte retrieved from the port doesn't change. I've also had a few problems with the -O2 option, but they are more difficult to reproduce. The problem goes away if I use the -O0 option or comment the portion of the code that uses inportb. GCC also seems to produce incorrect code when accessing the control registers (cr0 and cr3). -- ***** *** ** ** Dan M. Hedlund ** ** ***** *** ** ** ** ** ** **** ** http://www.rangenet.com/markiv ** ** ** ** ** ** ** ** ** ******* ** **** ** ** ** ** ** *** ** ** ** ** ** ** ***** ** ** ** **