This bug is seen using the avr-gcc that is built using the script that comes with FemtoOS 0.88.
Compile the attached program like this:
avr-gcc -O -mmcu=atmega128 small.c -S
It can be seen that func_45() unconditionally loads from volatile g_54. That is wrong, since in the C code the load is protected by a test.
Created attachment 17317 [details]
failure-inducing C program
Created attachment 17318 [details]
asm displaying volatile bug
Please fill out GCC version this bug is reported against.
Fail on 4.3.2 with -O1, success with -O[023s].
Fails with gcc 4.4.3 and gcc 4.5 with -O1.
An observation - the same file when compiled with -O1 for i386 target also appears to load g_54 using movl instruction.
testw %bx, %bx
movl _g_54, %eax
movl $1, 4(%esp)
(In reply to comment #6)
> An observation - the same file when compiled with -O1 for i386 target also
> appears to load g_54 using movl instruction.
> testw %bx, %bx
> je L7
> movl _g_54, %eax
> movl $1, 4(%esp)
It loads g_54 conditionally with gcc-4.4.0 and higher version in -O1
avr-gcc-4.4.0 -S -O1 small.c
code snippet version avr-gcc-4.4.0
.L__stack_usage = 0
(In reply to comment #5)
> Fails with gcc 4.4.3 and gcc 4.5 with -O1.
Correction : The bug passes with 4.4.2 and above versions. Code generated can be seen below.
(In reply to comment #9)
> (In reply to comment #5)
> Correction : The bug passes with 4.4.2 and above versions.
Closed as FIXED.