[Bug debug/88882] New: gcc generates wrong debug information at -O1

qrzhang at gatech dot edu gcc-bugzilla@gcc.gnu.org
Wed Jan 16 15:23:00 GMT 2019


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

            Bug ID: 88882
           Summary: gcc generates wrong debug information at -O1
           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 incorrectly prints "l = 0" at -O1. CC'ing alex..



$ 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.0/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.0 20181224 (experimental) [trunk revision 267411] (GCC)
$ gdb-trunk -v
GNU gdb (GDB) 8.2.50.20181223-git




It prints "l = 2" without optimization.

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

Breakpoint 1, main () at abc.c:9
9           optimize_me_not();
$1 = 2
Kill the program being debugged? (y or n) [answered Y; input not from terminal]
[Inferior 1 (process 11426) killed]


It incorrectly prints "l = 0" at -O1.

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

Breakpoint 1, main () at abc.c:9
9           optimize_me_not();
$1 = 0
Kill the program being debugged? (y or n) [answered Y; input not from terminal]
[Inferior 1 (process 11440) killed]


$ cat abc.c
int a;
int b;
int c;
int main() {
  for (; b;)
    ;
  int l = 2;
  for (; c < 2; c++)
    optimize_me_not();
  l = a;
}
$ cat outer.c
optimize_me_not() {}
$ cat cmds
b 9
r
p l
k
q


More information about the Gcc-bugs mailing list