[Bug middle-end/35856] New: Wrong CCP -- yielding wrong results at O1 and above

xinliangli at gmail dot com gcc-bugzilla@gcc.gnu.org
Mon Apr 7 07:07:00 GMT 2008


// Test case:  should print 0 but it prints 10 when compiled at -O or -O2. The
culprit is very likely ccp1.

#include <stdio.h>
int g;
int foo(int i, int j, int* flag)
{

   int t;

   if (i > 0 || j > 0)
   {
       t = 10;
       *flag = 1;
   }

   if (*flag)
        g+= t;
}

int main()
{
   int flag = 1;
   g = 0;

   foo(-1,-1,&flag);

   printf("g = %d \n",g );

  return g;
}


-- 
           Summary: Wrong CCP -- yielding wrong results at O1 and above
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: xinliangli at gmail dot com


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



More information about the Gcc-bugs mailing list