https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90131
Bug ID: 90131 Summary: wrong debug info at -O3 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: --- This issue is similar to bug 90074 --- same flag, same gcc versions. The bisection also points to r255267. It appears that the issue remains after the patch. $ gcc-trunk -v gcc version 9.0.1 20190417 (experimental) [trunk revision 270407] (GCC) $ gdb -v GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1 #Wrong result# $ gcc-trunk -g abc.c outer.c -O3 $ gdb -x cmds -batch a.out Breakpoint 1 at 0x40040f: file abc.c, line 16. Breakpoint 1, main () at abc.c:16 16 optimize_me_not(); $1 = 9 #Correct result# $ gcc-trunk -g abc.c outer.c $ gdb -x cmds -batch a.out Breakpoint 1 at 0x4004c8: file abc.c, line 16. Breakpoint 1, main () at abc.c:16 16 optimize_me_not(); $1 = 0 $ cat abc.c volatile long a; int b[9][1]; static short c[2][1] = {3}; int main() { int i, d, e; i = 0; for (; i < 9; i++) a = b[i][0]; i = 0; for (; i < 2; i++) { d = 0; for (; d < 1; d++) { e = 0; for (; e < 1; e++) a = c[i][e]; optimize_me_not(); } } } $ cat outer.c void optimize_me_not() {} $ cat cmds b 16 r p i kill q