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

            Bug ID: 89454
           Summary: gcc generates wrong debug information at -Og
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: qrzhang at gatech dot edu
  Target Milestone: ---

It bug affects the latest trunk.
It also affects gcc-8 to gcc-4.8.

With "-Og", it incorrectly prints "l=0".


$ gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/home/absozero/trunk/root-gcc/libexec/gcc/x86_64-pc-linux-gnu/9.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc/configure --prefix=/home/absozero/trunk/root-gcc
--enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
gcc version 9.0.1 20190222 (experimental) [trunk revision 269113] (GCC)


$ cat abc.c
int a;
int main() {
  char l = 0;
  if (a)
    ;
  else
    l = 10 || 0;
  optimize_me_not();
}

$ cat cmds
b 8
r
p l
kill
q

$ cat outer.c
optimize_me_not() {}


$ gcc-trunk -g  abc.c outer.c
$ gdb -x cmds -batch a.out
Breakpoint 1 at 0x40049c: file abc.c, line 8.

Breakpoint 1, main () at abc.c:8
8         optimize_me_not();
$1 = 1 '\001'
Kill the program being debugged? (y or n) [answered Y; input not from terminal]




$ gcc-trunk -g  abc.c outer.c -Og
$ gdb -x cmds -batch a.out
Breakpoint 1 at 0x400486: file abc.c, line 8.

Breakpoint 1, main () at abc.c:8
8         optimize_me_not();
$1 = 0 '\000'
Kill the program being debugged? (y or n) [answered Y; input not from terminal]

Reply via email to