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

--- Comment #10 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #8)
> Won't that break with function-local statics?  Those can certainly refer to
> other function-local static, with this patch gcc might think the other ones
> are unused.  I mean something like:
> 
> int **
> foo (void)
> {
>   static int a = 0;
>   static int *b = &a;
>   static int **c = &b;
>   return c;
> }

int **
foo (void)
{
  static int a = 0;
  static int *b = &a;
  static int **c = &b;
  return c;
}
int main()
{
  return **foo();
}

I can still step into foo() and print a, b and c when compiling with
-O -fno-inline -g (I cannot seem to step into foo with inlining enabled,
but that doesn't work without the patch either - didn't expect that
because we cannot preserve DECL_INITIAL in the inlined blocks).

Reply via email to