This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/42006] New: Termination problem with -O2 and -O3
- From: "chenyang at cs dot utah dot edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 11 Nov 2009 06:28:34 -0000
- Subject: [Bug c/42006] New: Termination problem with -O2 and -O3
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Using r154087, the code below never terminates with -O2 and -O3.
yang@yang-working:~$ svngcc -O2 -o small2 small.c
yang@yang-working:~$ ./small2
1
1
...
yang@yang-working:~$ ./small1
1
2
exit!
yang@yang-working:~$ cat small.c
#include <stdio.h>
static int
my_add(int si1, int si2)
{
return (si1 > (50-si2)) ? si1 : (si1 + si2);
}
static unsigned int
my_shift(unsigned int left, int right)
{
return (right > 100) ? left : (left >> right);
}
static int func_4(unsigned int p_6)
{
for (p_6 = 1; p_6 < 3; p_6 = my_add(p_6, 1))
{
printf ("%d\n", p_6);
if (my_shift(p_6, p_6))
{
return 0;
}
}
return 0;
}
int main(void)
{
func_4(0);
printf("exit!\n");
return 0;
}
yang@yang-working:~$ svngcc -v
Using built-in specs.
COLLECT_GCC=svngcc
COLLECT_LTO_WRAPPER=/home/yang/compilers/libexec/gcc/i686-pc-linux-gnu/4.5.0/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: ../configure --enable-lto --prefix=/home/yang/compilers
--program-prefix=svn --enable-languages=c,c++
--with-libelf=/home/yang/compilers : (reconfigured) ../configure --enable-lto
--prefix=/home/yang/compilers --program-prefix=svn
--with-libelf=/home/yang/compilers --enable-languages=c,lto,c++ --no-create
--no-recursion : (reconfigured) ../configure --enable-lto
--prefix=/home/yang/compilers --program-prefix=svn
--with-libelf=/home/yang/compilers --enable-languages=c,c++,lto --no-create
--no-recursion : (reconfigured) ../configure --enable-lto
--prefix=/home/yang/compilers --program-prefix=svn
--with-libelf=/home/yang/compilers --enable-languages=c,c++,lto --no-create
--no-recursion : (reconfigured) ../configure --enable-lto
--prefix=/home/yang/compilers --program-prefix=svn
--with-libelf=/home/yang/compilers --enable-languages=c,c++,lto --no-create
--no-recursion
Thread model: posix
gcc version 4.5.0 20091110 (experimental) (GCC)
--
Summary: Termination problem with -O2 and -O3
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: chenyang 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=42006