[Bug c/44928] New: volatile globals illegally ignored on optimization levels >0
asche at primion dot de
gcc-bugzilla@gcc.gnu.org
Tue Jul 13 15:45:00 GMT 2010
Hi there, the ARM compiler (we use 4.4.1 but could also verify this on
different platforms) illegally ignores the volatile statement on globals when
optimization >0 is used. Here is an example:
volatile unsigned char *glbDummyToTestVolatileBug;
...
<somewhere in a function body>:
for (glbDummyToTestVolatileBug=0;glbDummyToTestVolatileBug<(unsigned char
*)100;)
{
*glbDummyToTestVolatileBug++ = 0;
}
The generated assembly code will store the iteration in a register, not the
volatile global. Optimization level 0 will process this correctly.
Relevant compiler options being used are as follows:
-mthumb -mcpu=cortex-m3 -std=gnu99 -O3 -c -g -pedantic -Wall -Wextra
-fshort-enums
of course, the above code snippet is bogus, but is an abbreviated form of
something we rely on in our embedded controller.
Thanks!
--
Summary: volatile globals illegally ignored on optimization
levels >0
Product: gcc
Version: 4.4.1
Status: UNCONFIRMED
Severity: critical
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: asche at primion dot de
GCC build triplet: unknown
GCC host triplet: unknown (PC host not running cygwin)
GCC target triplet: arm-none-eabi
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44928
More information about the Gcc-bugs
mailing list