Tracking the 1) issue of http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43150#c2 here.
In f1 say -O2 -m64 -g we have in *.alignments: (debug_insn 7 14 8 2 vla-1.c:15 (var_location:DI D#2 (sign_extend:DI (plus:SI (reg/v:SI 5 di [orig:62 i ] [62]) (const_int 1 [0x1])))) -1 (nil)) (debug_insn 8 7 9 2 vla-1.c:15 (var_location:DI D#1 (plus:DI (debug_expr:DI D#2) (const_int -1 [0xffffffffffffffff]))) -1 (nil)) (debug_insn 9 8 10 2 vla-1.c:15 (var_location:DI D.2753 (debug_expr:DI D#1)) -1 (nil)) (insn:TI 10 9 33 2 vla-1.c:15 (parallel [ (set (reg:SI 5 di [63]) (plus:SI (reg/v:SI 5 di [orig:62 i ] [62]) (const_int 1 [0x1]))) (clobber (reg:CC 17 flags)) ]) 251 {*addsi_1} (expr_list:REG_UNUSED (reg:CC 17 flags) (nil))) var-tracking.c generates from this: (note 42 14 43 2 (var_location i (expr_list:REG_DEP_TRUE (reg:SI 5 di [ i ]) (const_int 0 [0x0]))) NOTE_INSN_VAR_LOCATION) (note 43 42 10 2 (var_location D.2753 (expr_list:REG_DEP_TRUE (plus:DI (sign_extend:DI (plus:SI (reg:SI 5 di [ i ]) (const_int 1 [0x1]))) (const_int -1 [0xffffffffffffffff])) (const_int 0 [0x0]))) NOTE_INSN_VAR_LOCATION) (insn:TI 10 43 44 2 vla-1.c:15 (parallel [ (set (reg:SI 5 di [63]) (plus:SI (reg/v:SI 5 di [orig:62 i ] [62]) (const_int 1 [0x1]))) (clobber (reg:CC 17 flags)) ]) 251 {*addsi_1} (expr_list:REG_UNUSED (reg:CC 17 flags) (nil))) (note 44 10 33 2 (var_location i (nil)) NOTE_INSN_VAR_LOCATION) but no further var_location note for D.2753. This is correct on the first insn in the function (both i has value 5 and sizeof (a) is 6), but after that insn i is unfortunately <optimized out> and sizeof (a) is incorrect (7). Wonder why var-tracking hasn't noticed that the value D.2753 is based on has changed. And, ideally, perhaps we could undo constant additions to values and subtract 1 in the debug insns (i.e. say that after the first insn i is in %rdi - 1 and D.2753 is sext (%rdi) - 1. -- Summary: Wrong debug info in guality/vla-1.c (f1) Product: gcc Version: 4.5.0 Status: UNCONFIRMED Keywords: wrong-debug Severity: normal Priority: P3 Component: debug AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jakub at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43160