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

--- Comment #7 from Hao Liu <hliu at amperecomputing dot com> ---
> 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.


> __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.

Reply via email to