------- Comment #2 from xinliangli at gmail dot com  2008-04-07 07:30 -------

Right, the source is buggy, but looks the compiler misses uninitialized warning
-- with -Wuninitialized -- no warning is given.

(In reply to comment #1)
> 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"
> <[EMAIL PROTECTED] 
>  > 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

Reply via email to