http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47391
Summary: read from const volatile incorrectly eliminated
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: [email protected]
ReportedBy: [email protected]
I'm using r169046 on x86 Linux.
The problem is that this code:
const volatile int g_2 = 1;
int g_1 = 0;
void func_1 (void) {
g_1 = g_2;
}
int main (void) {
func_1();
return 0;
}
Compiled like this:
current-gcc -O2 -S small.c
Gives this main():
main:
movl $1, g_1
xorl %eax, %eax
ret
The load from g_2 shouldn't have been removed. Oddly, the load is not
eliminated from func_1(), nor is it eliminated from main if we inline the
function by hand.