Looks like it's version 2.21...
That's what I thought. It's a bug in binutils. Bummer.
You have found one workaround: Make sure your sketch uses a global variable. At least it fixes it for this simple sketch.
I am not aware of other bugs, but once you see one flaky thing like this, any time in the future that something doesn't work as expected, your mind will inevitably go in the direction that, "maybe something is wrong with the tools." Too bad.
What version of avr-gcc is in your distribution?
Try running:
avr-gcc --versionMaybe you can compile from source and use binutils-2.20.1
For my Centos 5 workstations (same as RedHat EL 5) I followed the sequence detailed here:
http://www.nongnu.org/avr-libc/user-manual/install_tools.html, using binutils version 2.20.1, avr-gcc version 4.3.4, and avr-libc version 1.6.8
Or you can live with what you have until and unless you discover some other bug for which there is no workaround.
Regards,
Dave
Footnote:This version of compiler does not support the ATmega2560 without some patch(es). Since I don't have an Arduino Mega2560 board, I have no way of testing, so I haven't tried. I have used the above combination for '328p boards and '1280 boards that I have. Note that if you do compile from source you should compile all three. At least that was my experience.