This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/35729] New: const volatile variable accessed that should not be
- From: "regehr at cs dot utah dot edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 28 Mar 2008 03:04:49 -0000
- Subject: [Bug c/35729] New: const volatile variable accessed that should not be
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
This is for "gcc version 4.3.0 (GCC)"
func_1() here should never load from g_361 since the loop body never executes:
const volatile int g_361 = 3L;
volatile int g_2 = 0L;
void func_1 (void) {
for (g_2 = 0; g_2 > 10; g_2++)
{
int l_357 = g_361;
}
}
However when compiled with "gcc -Os -S foo.c" we get the following output which
does load from g_361:
.file "foo.c"
.text
.globl func_1
.type func_1, @function
func_1:
pushl %ebp
movl %esp, %ebp
movl $0, g_2
movl g_361, %eax
jmp .L2
.L3:
movl g_2, %eax
incl %eax
movl %eax, g_2
.L2:
movl g_2, %eax
cmpl $10, %eax
jg .L3
popl %ebp
ret
.size func_1, .-func_1
.globl g_361
.data
.align 4
.type g_361, @object
.size g_361, 4
g_361:
.long 3
.globl g_2
.bss
.align 4
.type g_2, @object
.size g_2, 4
g_2:
.zero 4
.ident "GCC: (GNU) 4.3.0"
.section .note.GNU-stack,"",@progbits
At -O0, -O1, and -O2 there is no problem.
--
Summary: const volatile variable accessed that should not be
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: regehr at cs dot utah dot edu
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35729