avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-gcc-list] volatile bug in GCC?


From: Janne Heikkinen
Subject: [avr-gcc-list] volatile bug in GCC?
Date: Mon, 12 Aug 2002 03:37:50 +0300

Following code produces weird behaviour when compiled with
GCC 3.1.1 or 3.3:

#include <stdlib.h>

volatile char *ptr=NULL;

volatile int i=0;

main()
{
    while(i);

    while(ptr);
}

After compiling with:

avr-gcc -mmcu=at90s8515 -Os -S t.c

and looking at t.s:

main:
/* prologue: frame size=0 */
        ldi r28,lo8(__stack - 0)
        ldi r29,hi8(__stack - 0)
        out __SP_H__,r29
        out __SP_L__,r28
/* prologue end (size=4) */
.L2:
        lds r24,i
        lds r25,(i)+1
        or r24,r25
        brne .L2
        lds r24,ptr
        lds r25,(ptr)+1
.L5:
        sbiw r24,0
        brne .L5
/* epilogue: frame size=0 */
        rjmp exit

First it won't reload ptr like it should  and second it won't check
it's value properly.

Janne Heikkinen

avr-gcc-list at http://avr1.org



reply via email to

[Prev in Thread] Current Thread [Next in Thread]