Arduino compiler bug number 2

I would like these controllers better if the compiler were not so buggy. Here is a simple piece of code intended to send pulses (a square wave) on a pin:
/* Send pulses on selected pin
 */
const int ioPin = 2;

void setup(void)
{
  pinMode ( ioPin, OUTPUT );

#ifdef notdef
  for ( ;; ) {
    digitalWrite ( ioPin, HIGH );
    digitalWrite ( ioPin, LOW );
  }
#endif
}

byte pin = LOW;

void loop ( void )
{
       digitalWrite ( ioPin, pin );

        if ( pin == LOW ) {
            pin = HIGH;
        } else {
            pin = LOW;
        }

}
/* THE END */
This code should work, but what it does is to set the pin to a LOW state and sit there forever. If I change one line to the following, it works:
byte pin = HIGH;
Clearly some kind of compiler bug. I am using avr-gcc (Fedora 4.5.3-1.fc14) 4.5.3 as of 10-4-2011 This is the latest version available as an RPM package for Fedora 14 at this time. A newer version of the compiler is available, and who knows, might fix the problem.

Nonetheless, it is disturbing that these chips have been on the market for years and the compiler still has bugs.


Feedback? Questions? Drop me a line!

Tom's Computer Info / tom@mmto.org