Problem with modulo (%) and reset

void loop() {
  n1000 = ldiv(m++,1000000L);  // This hangs Arduino while pressing reset
}

By "hang" you mean that it goes into some sort of bootloader loop where you get the initial flashes, repeating approximately every second, but the sketch itself never seems to start?

I can get this to happen with an m168 containing optiboot, using 0022 from a Mac. Not every time, though.

This is really strange. It's not really hung, or it wouldn't be running the bootloader enough to flash the LEDs. Or to recover on a new upload. The ldiv function really doesn't do anything suspicious that I can see...