https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90946
Bug ID: 90946 Summary: gcc generates wrong debug information 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: --- It affects the trunk at "-O3". The expected output is "105487". However, at -O3, it prints "40369". Bisect points to r270902. $ gcc-trunk -v gcc version 10.0.0 20190619 (experimental) [trunk revision 272472] (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 0x40052d: file abc.c, line 30. Breakpoint 1, g (j=1) at abc.c:30 30 optimize_me_not(); $1 = 105487 #Wrong output# $ gcc-trunk -g abc.c outer.c -O3 $ gdb -x cmds -batch a.out Breakpoint 1 at 0x400396: file abc.c, line 30. Breakpoint 1, g (j=1) at abc.c:30 30 optimize_me_not(); $1 = 40369 $ cat abc.c static short a = 8; int b, f, h; int *c; volatile int d; int e(j) {} static char g(j) { unsigned short k; int l_756 = 40369, i = 0; int *l = &l_756; for (; i < 4; i++) f = 4071609; if (f) { int m[1]; if (j) ; else { int **n = &c; *n = e(&l_756); **n = h; **n |= 0; } } else { k = b; *c = k; h &= 8; } d; if (a) { *l = 105487; optimize_me_not(); return 8; } int o = &l; } int main() { g(1); } $ cat outer.c void optimize_me_not() {} $ cat cmds b 30 r p l_756 kill q