http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45852
Summary: volatile structs are broken! Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassig...@gcc.gnu.org ReportedBy: reg...@cs.utah.edu CC: cheny...@cs.utah.edu gcc should not be optimizing away the read from or write to this struct. reg...@john-home:~$ current-gcc -v Using built-in specs. COLLECT_GCC=current-gcc COLLECT_LTO_WRAPPER=/home/regehr/z/compiler-install/gcc-r164818-install/libexec/gcc/i686-pc-linux-gnu/4.6.0/lto-wrapper Target: i686-pc-linux-gnu Configured with: ../configure --with-libelf=/usr/local --enable-lto --prefix=/home/regehr/z/compiler-install/gcc-r164818-install --program-prefix=r164818- --enable-languages=c,c++ Thread model: posix gcc version 4.6.0 20100930 (experimental) (GCC) reg...@john-home:~$ current-gcc -S -o - -O1 small.c .file "small.c" .text .globl func_1 .type func_1, @function func_1: .LFB0: .cfi_startproc rep ret .cfi_endproc .LFE0: .size func_1, .-func_1 .globl g_18 .data .align 4 .type g_18, @object .size g_18, 4 g_18: .long -6 .ident "GCC: (GNU) 4.6.0 20100930 (experimental)" .section .note.GNU-stack,"",@progbits reg...@john-home:~$ cat small.c struct S1 { int f0; }; volatile struct S1 g_18 = { -6 }; void func_1 (void) { g_18 = g_18; }