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

--- Comment #2 from Alfred Agrell <blubban at gmail dot com> ---
Poked this thing a bit more, and discovered that there's no need for inlining,
you can reproduce it just as well with an extra {}.

And if you copy the function a few times, the warnings start pointing to wrong
source location. Is that just another facet of this issue, or is it a separate
bug?


$ gcc -O2 -Wall bug.c

int foo1() { int * b; { int a = 1; b = &a; } return *b; }
int foo2() { int * b; { int a = 2; b = &a; } return *b; }
int foo3() { int * b; { int a = 3; b = &a; } return *b; }
int foo4() { int * b; { int a = 4; b = &a; } return *b; }
int foo5() { int * b; { int a = 5; b = &a; } return *b; }


<source>: In function 'foo1':
<source>:1:54: warning: 'a' is used uninitialized in this function
[-Wuninitialized]
    1 | int foo1() { int * b; { int a = 1; b = &a; } return *b; }
      |                                                     ^~
<source>: In function 'foo2':
<source>:1:29: warning: 'a' is used uninitialized in this function
[-Wuninitialized]
    1 | int foo1() { int * b; { int a = 1; b = &a; } return *b; }
      |                             ^
<source>: In function 'foo3':
<source>:1:29: warning: 'a' is used uninitialized in this function
[-Wuninitialized]
<source>: In function 'foo4':
<source>:1:29: warning: 'a' is used uninitialized in this function
[-Wuninitialized]
<source>: In function 'foo5':
<source>:1:29: warning: 'a' is used uninitialized in this function
[-Wuninitialized]

Reply via email to