[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Bug or bad optimization?
From: |
David Brown |
Subject: |
Re: [avr-gcc-list] Bug or bad optimization? |
Date: |
Thu, 3 Mar 2005 09:13:36 +0100 |
Klass,
This is completely wrong. As a basic rule, if optomisation levels change
the functionality of the code, then your code is wrong (unless there is a
bug in the optomiser - unlikely, but possible in the "experimental"
optomisation passes). The correct answer, without any doubt, is to use
"volatile" in the decleration of command, telling the compiler to re-read
the memory each run through the loop, which is exactly what you want. If
your second "solution" works at all, it is by luck - the compiler would be
free to treat it exactly like the original while() loop.
For those that like urls:
http://www.nongnu.org/avr-libc/user-manual/FAQ.html#faq_volatile
mvh.,
David
>
> Hi,
>
> Had a similar problem. Try the following:
> Change: avr-gcc -S -mmcu=atmega128 -I. -gstabs -Os -funsigned-char
> -funsigned-bitf
> To: avr-gcc -S -mmcu=atmega128 -I. -gstabs -O0 -funsigned-char
> -funsigned-bitf
> (Switch off optimization)
>
> If you want to use optimization try this less elegant solution:
>
> RD_CMD:
> if(command == NULL) {
> goto RD_CMD;
> }
> // wait for command in uart getchar
>
> Regards,
> Klaas korterink
>
- Re: [avr-gcc-list] Kindness and respect., (continued)
- Re: [avr-gcc-list] Kindness and respect., E. Weddington, 2005/03/02
- RE: [avr-gcc-list] Kindness and respect., Jim Davis, 2005/03/02
- Re: [avr-gcc-list] Kindness and respect., Jeff Barlow, 2005/03/02
- Re: [avr-gcc-list] Kindness and respect., E. Weddington, 2005/03/02
- [avr-gcc-list] avr-gcc-list] Kindness and respect., Alan Kilian, 2005/03/02
- Re: [avr-gcc-list] avr-gcc-list] Kindness and respect., David Brown, 2005/03/03
- Re: [avr-gcc-list] Kindness and respect., Graham Davies, 2005/03/03
- RE: [avr-gcc-list] Kindness and respect., Dave Hansen, 2005/03/02
- RE: [avr-gcc-list] Kindness and respect., Jim Davis, 2005/03/02
RE: [avr-gcc-list] Bug or bad optimization?, Klaas K., 2005/03/03
- Re: [avr-gcc-list] Bug or bad optimization?,
David Brown <=
RE: [avr-gcc-list] Bug or bad optimization?, Dave Hylands, 2005/03/02