Arduino Mega 1280 delay() turbocharged

stimmer:
Yes, it sounds like an Arch specific problem at the moment. Maintaining a cross compiler is probably one of the harder jobs, they are a pain to compile and bug reports are hard to replicate.

A potential solution has been posted in another thread by dsh1. This involves downgrading to GCC 4.3.5 and applying Debian patches:

Incrementation bug? WTF? [BROKEN COMPILER - SOLVED] - #21 by system - Programming Questions - Arduino Forum

Can people try this and see if it works?

I just thought I would mention that I'm having this problem with Gentoo as well. I'm using:

$ avr-gcc -v
Using built-in specs.
Target: avr
Configured with: /var/tmp/portage/cross-avr/gcc-4.3.3-r2/work/gcc-4.3.3/configure --prefix=/usr --bindir=/usr/i686-pc-linux-gnu/avr/gcc-bin/4.3.3 --includedir=/usr/lib/gcc/avr/4.3.3/include --datadir=/usr/share/gcc-data/avr/4.3.3 --mandir=/usr/share/gcc-data/avr/4.3.3/man --infodir=/usr/share/gcc-data/avr/4.3.3/info --with-gxx-include-dir=/usr/lib/gcc/avr/4.3.3/include/g++-v4 --host=i686-pc-linux-gnu --target=avr --build=i686-pc-linux-gnu --disable-altivec --disable-fixed-point --enable-nls --without-included-gettext --with-system-zlib --disable-werror --enable-secureplt --disable-libmudflap --disable-libssp --enable-cld --enable-checking=release --disable-libgcj --enable-languages=c,c++ --enable-shared --disable-threads --disable-bootstrap --with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.3.3-r2 p1.2, pie-10.1.5'
Thread model: single
gcc version 4.3.3 (Gentoo 4.3.3-r2 p1.2, pie-10.1.5)

I've been discussing this in #arduino, and we're working around this issue so far like this: (with a 0022 ide)

$ diff -u5 hardware/arduino/cores/arduino/wiring.{c_orig,c}
--- hardware/arduino/cores/arduino/wiring.c_orig	2011-02-05 18:17:40.058000066 -0600
+++ hardware/arduino/cores/arduino/wiring.c	2011-02-05 18:19:32.907000066 -0600
@@ -21,10 +21,11 @@
 
   $Id$
 */
 
 #include "wiring_private.h"
+#include <avr/delay.h>
 
 // the prescaler is set so that timer0 ticks every 64 clock cycles, and the
 // the overflow handler is called every 256 ticks.
 #define MICROSECONDS_PER_TIMER0_OVERFLOW (clockCyclesToMicroseconds(64 * 256))
 
@@ -102,18 +103,21 @@
 	return ((m << 8) + t) * (64 / clockCyclesPerMicrosecond());
 }
 
 void delay(unsigned long ms)
 {
+/*	
 	uint16_t start = (uint16_t)micros();
 
 	while (ms > 0) {
 		if (((uint16_t)micros() - start) >= 1000) {
 			ms--;
 			start += 1000;
 		}
 	}
+*/
+	_delay_ms(ms);
 }
 
 /* Delay for the given number of microseconds.  Assumes a 8 or 16 MHz clock. */
 void delayMicroseconds(unsigned int us)
 {

I have also found that using the 0018 IDE, the delay() works properly.

I'll have a look at the Debian patches you listed, and report back when I know more.