https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110531

--- Comment #8 from Kewen Lin <linkw at gcc dot gnu.org> ---
(In reply to Hao Liu from comment #7)
> > int foo() {
> >   bool a = true;
> >   bool b;
> >   if (a || b)
> >     return 1;
> >   b = true;
> >   return 0;
> > }
> > 
> > still has the warning, it looks something can be improved (guess we prefer 
> > not to emit warning).
> 
> Your case is wrong, you should initialize "b" and there will be no warning.
> 

I don't follow why it is wrong, doesn't short-circuiting make b uninitialized
trivial?

> 
> > __attribute__((noipa)) int foo(int *a) { *a = 1; return 1;}
> > 
> > int test(){
> > #ifdef AINIT
> >   int a = 0;
> > #else
> >   int a;
> > #endif
> >   int b = foo(&a);
> >   return b;
> > }
> 
> This case doesn't have problem. If "foo" uses "a" directly, the result is
> undefined behavior, which causes both correctness and performance issues.

foo is just an example for not getting inlined, the point here is extra cost
paid.

Reply via email to