This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/33498] New: Optimizer (-O2) may convert a normal loop to infinite
- From: "dada1 at cosmosbay dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 19 Sep 2007 15:02:08 -0000
- Subject: [Bug c/33498] New: Optimizer (-O2) may convert a normal loop to infinite
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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