This is GCC Bugzilla
This is GCC Bugzilla Version 2.20+
View Bug Activity | Format For Printing | Clone This Bug
This is seen on the version of avr-gcc 4.3.3 that gets built by the script that comes with FemtoOS 0.88. The program performs simple arithmatic and logical operations on a global variable, and store the result in register R30:R31. If the program is compiled with "avr-gcc -mmcu=atmega128 -O0", the final result is 00. On the other hand, if the program is compiled with "avr-gcc -mmcu=atmega128 -O1", the final result is 0xFF. Compiling at O2 gives me 0xFF too. Obviously, avr-gcc compiled the program wrong at one of the these optimization levels. This bug is observed in avr studio 4.15.
Created an attachment (id=17400) [edit] mis-calculated program
Confirmed with gcc 4.3.2.
Please try using gcc 4.4 (HEAD). Anatoly Sokolov (AVR port maintainer) has indicated to me that he does not see this bug when using HEAD/4.4.
*** Bug 39635 has been marked as a duplicate of this bug. ***
Adding additional version numbers in the known-to-fail field from comment in duplicate bug #39635. Still waiting to hear if bug is present in 4.4.
Confirmed with gcc 4.4.0. Using switch -O0 with avr-gcc 4.4.0 (-mmcu=atmega128) gave the result 0 while -O1 gave 0xFF