[Bug target/71053] [6/7 Regression] Volatile read optimized into endless loop
bseifert at gmx dot at
gcc-bugzilla@gcc.gnu.org
Thu May 12 09:49:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71053
Berni <bseifert at gmx dot at> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bseifert at gmx dot at
--- Comment #3 from Berni <bseifert at gmx dot at> ---
I also reproduced the bug after building the avr gcc 6.1.0 tool chain.
if you wait for the ADC to complete a measurement, you use the following code:
while (ADCSRA & _BV(ADSC));
which looks like the following after the post processor:
while ((*(volatile uint8_t *)(0x7A)) & (1 << (6)));
which looks fine, but it compiles to:
3c38: 80 91 7a 00 lds r24, 0x007A
3c3c: 80 74 andi r24, 0x40 ; 64
3c3e: 81 11 cpse r24, r1
3c40: fe cf rjmp .-4 ; 0x3c3e <main+0x12>
this is an endless loop. It does not respect the volatile keyword.
More information about the Gcc-bugs
mailing list