This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/36124] New: conditional loop becomes infinite loop in -O2 (gcc 4.2 -> 4.3 regression)
- From: "cyprien+gccbug at cypou dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 4 May 2008 16:25:20 -0000
- Subject: [Bug c/36124] New: conditional loop becomes infinite loop in -O2 (gcc 4.2 -> 4.3 regression)
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Hi,
It seems to have some regression in gcc 4.3, visible on arm targets as well as
x86_64.
I originally already reported it to Debian bugtracking system
[http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=472867]
I tested it against the latest gcc snapshot:
gcc (GCC) 4.3.1 20080501 (prerelease)
gcc has been built with no option, only srcdir/configure && make.
preprocessed content:
# 1 "c.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "c.c"
extern void func(void*);
void test()
{
register long *foo = (long*) 1024;
register int index;
for(index=0;index<1024;index++)
func(foo--);
}
This is a simple loop indexed on an integer. It should be finite, but when
compiling with -O2 (and -O3) the compiler removes the end condition.
gcc -S -O2 extract:
.LCFI0:
movl $1024, %edi
.p2align 4,,10
.p2align 3
.L2:
leaq -8(%rdi), %rbx
call func
movq %rbx, %rdi
jmp .L2
Note that when using char* or non-pointer type for foo variable, it compiles
successfully.
--
Summary: conditional loop becomes infinite loop in -O2 (gcc 4.2 -
> 4.3 regression)
Product: gcc
Version: 4.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: cyprien+gccbug at cypou dot net
GCC build triplet: x86_64-unknown-linux-gnu
GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36124