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

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



------- Comment #1 from pinskia at gmail dot com  2008-04-07 07:10 -------
Subject: Re:   New: Wrong CCP -- yielding wrong results at O1 and above



Sent from my iPhone

On Apr 7, 2008, at 0:06, "xinliangli at gmail dot com"
<gcc-bugzilla@gcc.gnu.org 
 > wrote:

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

I don't think it should t used uninitialized if *flag is true and both  
I and j is less than zero which is true in this case.

>
>
> #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
>


-- 


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



More information about the Gcc-bugs mailing list