[Bug c/33498] New: Optimizer (-O2) may convert a normal loop to infinite
dada1 at cosmosbay dot com
gcc-bugzilla@gcc.gnu.org
Wed Sep 19 15:02:00 GMT 2007
gcc-4.2.0 and gcc-4.2.1 cannot compile properly this function if -O2 is
selected
It generates an infinite loop :(
No problem for previous version (gcc-4.1.2 is OK)
$ cat bug.c
void table_init(int *value)
{
int i;
int val = 0x03020100;
for (i = 0; i < 256/4; i++) {
value[i] = val;
val += 0x04040404;
}
}
$ gcc -O2 -S bug.c
$ cat bug.s
.file "bug.c"
.text
.p2align 4,,15
.globl table_init
.type table_init, @function
table_init:
pushl %ebp
movl $50462976, %edx
movl %esp, %ebp
movl $1, %eax
movl 8(%ebp), %ecx
.p2align 4,,7
.L2:
movl %edx, -4(%ecx,%eax,4)
addl $67372036, %edx
addl $1, %eax
jmp .L2
.size table_init, .-table_init
.ident "GCC: (GNU) 4.2.1"
.section .note.GNU-stack,"",@progbits
--
Summary: Optimizer (-O2) may convert a normal loop to infinite
Product: gcc
Version: 4.2.1
Status: UNCONFIRMED
Severity: critical
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: dada1 at cosmosbay dot com
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=33498
More information about the Gcc-bugs
mailing list