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

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Guess it's the same bug as with C99 or C++ where you can write

const char *st = "Shall we?";
int main()
{
  printf ("%s\n", st);
  printf ("%s\n", "Before assignment");
  const char *st = "Hello, world!";
  printf ("%s\n", st);
  return 0;
}

(gdb) start
Temporary breakpoint 1, main () at t.c:5
5         printf ("%s\n", st);
(gdb) p st
$1 = 0x0
(gdb) n
Shall we?
6         printf ("%s\n", "Before assignment");
(gdb) p st
$2 = 0x0
(gdb) n
Before assignment
7         const char *st = "Hello, world!";
(gdb) p st
$3 = 0x0
(gdb) n
8         printf ("%s\n", st);
(gdb) p st
$4 = 0x4005c0 "Hello, world!"

and there's a duplicate PR about this.  The only way to capture these may
be to introduce additional scoping in the FEs whenever new local decls
are added.  Also consider

  const char *oldst = st;
  const char *st = "Hello, world!";

so even consecutive inits may need two separate scopes.

Reply via email to