This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/47391] New: read from const volatile incorrectly eliminated
- From: "regehr at cs dot utah.edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 21 Jan 2011 05:51:56 +0000
- Subject: [Bug c/47391] New: read from const volatile incorrectly eliminated
- Auto-submitted: auto-generated
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: unassigned@gcc.gnu.org
ReportedBy: regehr@cs.utah.edu
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.