http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47409
--- Comment #18 from Richard Biener <rguenth at gcc dot gnu.org> --- (In reply to Francesco Zappa Nardelli from comment #16) > Dear all > > a possibly related issue. Consider > > struct S1 { > long f; > }; > volatile struct S1 g; > > struct S1 func_1 () { > return g; > } > > void main () { > func_1 (); > } > > This program, if compiled with a recent gcc svn: > > $ gcc -v > Target: x86_64-unknown-linux-gnu > gcc version 4.9.0 20130625 (experimental) (GCC) > > correctly loads the long at g.f at -O0. However the assembly generated at > -O2: > > func_1: > movq g(%rip), %rax > ret > main: > rep; ret > > does not perform the volatile load access, which, as far as I understand, is > incorrect. It does starting with GCC 4.8.2 and was a bug in older GCC versions. Richard. > -francesco