Problem with too good optimization

Doug Evans
Mon Nov 1 10:45:00 GMT 1999

   Date: Mon, 01 Nov 1999 19:04:43 +0100
   From: Kai Schaeffer <>

   I have a little Problem, with the optimization of the gcc (m68k, version
   2.8.1). I want to wait until a value of a variable changes. So I write
   something like that:

   char c;


   The changing of 'c' happens in an interrupt routine. If I turn the
   optimization with -O2 on, the compiler produces code like this:

	move.b c,%d0
	tst.b %d0
	jbne .L6

   Of course the programm doesn't notice the changing of the value of 'c'. Are
   there any arguments for a variable that the compiler doesn't use a register?

The canonical solution is to change

char c;


volatile char c;

Want more information?  See the CrossGCC FAQ,
Want to unsubscribe? Send a note to

More information about the crossgcc mailing list