https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88730
Bug ID: 88730 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: --- Unlike PR88686, it happens at -Og. The correct value of j should be 5. At "-Og", gdb prints "j = 2" incorrectly. $ 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 20190106 (experimental) [trunk revision 267609] (GCC) $ gcc-trunk -g abc.c outer.c $ gdb-trunk -x cmds -batch a.out Breakpoint 1 at 0x400507: file abc.c, line 11. 0 Breakpoint 1, main () at abc.c:11 11 optimize_me_not(); $1 = 5 $ gcc-trunk -g -Og abc.c outer.c $ gdb-trunk -x cmds -batch a.out Breakpoint 1 at 0x4004e4: file abc.c, line 11. 0 Breakpoint 1, main () at abc.c:11 11 optimize_me_not(); $1 = 2 =============== files to reproduce ============ $ cat abc.c int a; int main() { int b, j; b = 0; for (; b < 1; b++) { j = 0; for (; j < 5; j++) ; } printf("%X\n", a); optimize_me_not(); } $ cat outer.c optimize_me_not(){} $ cat cmds b 11 r p j kill q