https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89791
Bug ID: 89791 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 gcc-4.6 to gcc-trunk. The expected output is "i=7" or <optimized out>. With "-O3", it outputs "i=0". I am using two files since "noipa" attribute directive is not supported in early gcc versions. Bisect points to r154402. commit 43e54ec3e93dd2ef495375ead1f1eac467a727d1 Author: aoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Sat Nov 21 05:06:24 2009 +0000 * tree-ssa.c (find_released_ssa_name): Handle NULL wi. (insert_debug_temp_for_var_def): Handle degenerate PHI nodes. (insert_debug_temps_for_defs): Handle PHI nodes. * tree-ssa-dom.c (degenerate_phi_result): Don't crash on released SSA names. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154402 138bc75d-0d04-0410-961f-82ee72b054a4 $ gcc-trunk -v gcc version 9.0.1 20190321 (experimental) [trunk revision 269832] (GCC) $ cat abc.c int main() { int i = 0; for (; i < 7; i++) ; optimize_me_not(); } $ cat outer.c void optimize_me_not() {} # correct output # $ gcc-trunk -g abc.c outer.c $ gdb -x cmds -batch a.out Breakpoint 1 at 0x40046d: file abc.c, line 5. Breakpoint 1, main () at abc.c:5 5 optimize_me_not(); $1 = 7 # Wrong output # $ gcc-trunk -g abc.c outer.c $ gdb -x cmds -batch a.out Breakpoint 1 at 0x400380: file abc.c, line 5. Breakpoint 1, main () at abc.c:5 5 optimize_me_not(); $1 = 0