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

            Bug ID: 89529
           Summary: Wrong debug info generated at -Og [gcc-trunk]
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dccitaliano at gmail dot com
  Target Milestone: ---

$ cat 2.c
int a;
void b() {
  short l_1862 = 19071;
  a = 0;
  for (; 0;)
    optimize_me_not();
  --l_1862;
}
int main() { b(); }

$ cat outer.c
void optimize_me_not() {}

### -Og

Reading symbols from ./a.out...
(gdb) b 6
Breakpoint 1 at 0x40048c: file 2.c, line 7.
(gdb) r
Starting program: /home/davide/finished-reducing-gcc/a.out

Breakpoint 1, b () at 2.c:7
7         --l_1862;
(gdb) frame var
No symbol "var" in current context.
(gdb) info locals
l_1862 = 19070

### -O0

Reading symbols from ./a.out...
(gdb) b 6
Breakpoint 1 at 0x400497: file 2.c, line 7.
(gdb) r
Starting program: /home/davide/finished-reducing-gcc/a.out

Breakpoint 1, b () at 2.c:7
7         --l_1862;
(gdb) info locals
l_1862 = 19071

$ gcc-trunk --version
gcc-trunk (GCC) 9.0.1 20190227 (experimental) [trunk revision 269248]
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ gdb-trunk --version
GNU gdb (GDB) 8.3.50.20190227-git
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Reply via email to