https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89905
Bug ID: 89905 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 affects gcc-8 to trunk. Gcc-7 works fine. Bisection points to r247596. The correct value is "i=830100328". However, with "-Og", gdb outputs "i=830100327". $ gcc-trunk -v gcc version 9.0.1 20190401 (experimental) [trunk revision 270054] (GCC) $ gdb -v GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1 #correct output# $ gcc-trunk -g abc.c outer.c $ gdb -x cmds -batch a.out Breakpoint 1 at 0x40057a: file abc.c, line 22. Breakpoint 1, i () at abc.c:22 22 optimize_me_not(); $1 = 830100328 #incorrect output# $ gcc-trunk -g abc.c outer.c -Og $ gdb -x cmds -batch a.out Breakpoint 1 at 0x4004f3: file abc.c, line 22. Breakpoint 1, i () at abc.c:22 22 optimize_me_not(); $1 = 830100327 $ cat abc.c char c, d = 22, f; short e, g; int h; char(a)() {} char(b)() { return 0; } void i() { char j; for (; h < 1;) { short k[9] = {1, 1, 1, 1, 1, 1, 1, 1, 1}; int l, i = 830100327; short m[3] = {0, 0, 0}; for (; h < 7; h++) for (; d >= 33;) { ++k[8]; f = (c || a()) && g; } i++; j = b() || m[2]; l = 0; for (; l <= 6; l = d) e = k[8]; optimize_me_not(); } } int main() { i(); } $ cat cmds b 22 r p i kill q $ cat outer.c void optimize_me_not() {}