http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56488



             Bug #: 56488

           Summary: wrong code for loop at -O3

    Classification: Unclassified

           Product: gcc

           Version: 4.7.2

            Status: UNCONFIRMED

          Severity: normal

          Priority: P3

         Component: tree-optimization

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: dhaze...@yahoo.com





The following code (reduced from a larger testcase) when compiled at -O3 with

gcc 4.7.2 produces an executable that does not terminate.  Compiling with lower

optimizations, current gcc trunk or the older 4.6.3 release at -O3, the

executable terminates as expected.





$ gcc-4.7 --version

gcc-4.7 (GCC) 4.7.2

$ gcc-4.7 -O2 loop.c

$ ./a.out 

$ gcc-4.6 -O3 loop.c

$ ./a.out 

$ gcc-4.7 -O3 loop.c

$ ./a.out 

<hangs> ^C

$ cat loop.c



int a, c, d = 1;



struct

{

    int f0;

} b, f;



short e;



void fn1 (p1)

{

    int g[] = { };

    e = 0;

    for (; e != 1; e = e + 5)

    {

        int *h[] = {[0] & g[0] };

        if (p1);

        else

            return;

        f = b;

    }

}



int main ()

{

    int i, j;

    i = 0;

    for (; i < 6; i++)

    {

        j = 8;

        for (; j; j--)

            a = 0;

    }

    fn1 (d);

    for (; c;);

}

Reply via email to