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

            Bug ID: 95865
           Summary: Wrong line information at Og
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: massarelli at diag dot uniroma1.it
  Target Milestone: ---

$ cat a.c
int g_4 = 3, a;
int *b() {
  if (g_4)
    return &g_4; //line 4
  a = 0;
  return &g_4; //line 6
}

$ cat -n a.c
     1  int g_4 = 3, a;
     2  int *b() {
     3    if (g_4)
     4      return &g_4; //line 4
     5    a = 0;
     6    return &g_4; //line 6
     7  }
     8  int main() { b(); }

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/bin/../libexec/gcc/x86_64-pc-linux-gnu/11.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ./configure --prefix=/tmp/gcc_build --disable-multilib
--enable-languages=c,c++
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.0.0 20200619 (experimental) (GCC) 

$ gdb -v
GNU gdb (Ubuntu 8.1-0ubuntu3.2) 8.1.0.20180409-git

$ gcc -Og -g -o out a.c

$ gdb out
Reading symbols from out...done.
(gdb) b main
Breakpoint 1 at 0x40049f: file a.c, line 8.
(gdb) r
Starting program: out 
Breakpoint 1, main () at a.c:8
8       int main() { b(); }
(gdb) s
b () at a.c:3
3         if (g_4)
(gdb) p g_4
$1 = 3
(gdb) s
6         return &g_4; //line 6
(gdb) s
0x00007ffff7a05b97 in __libc_start_main () from /lib/x86_64-linux-gnu/libc.so.6
(gdb)

Reply via email to