https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105108
--- Comment #8 from Cristian Assaiante <assaiante at diag dot uniroma1.it> ---
(In reply to Jakub Jelinek from comment #3)
> And I certainly can't reproduce the wrong-debug issue you're talking about.
> If I change it to char l_144 = 8;
> then optimized dump has:
> <bb 2> [local count: 1073741824]:
> # DEBUG BEGIN_STMT
> # DEBUG l_144 => 8
> # DEBUG BEGIN_STMT
> # DEBUG l_165 => 128
> # DEBUG BEGIN_STMT
> # DEBUG l_144 => NULL
> # DEBUG BEGIN_STMT
> a = 1;
> return 0;
> and in the debugger it correctly says that
> (gdb) p l_144
> $1 = <optimized out>
> because at the a = 1 store the value is unknown.
I have tested again the C example with l_144 = 8 and in gdb l_144 is not marked
as optimized out, instead it has 8 as value:
$ cat a.c
int a;
char b() { return 0; }
int main() {
char l_144 = 8;
short l_165 = 128;
l_144 = b();
a = l_144 != l_165;
}
$ gcc -Og -g a.c -o opt
DWARF info for l_144:
0x0000006b: DW_TAG_variable
DW_AT_name ("l_144")
DW_AT_decl_file ("/home/stepping/a.c")
DW_AT_decl_line (4)
DW_AT_decl_column (0x07)
DW_AT_type (0x0000008d "char")
DW_AT_location (0x0000000e:
[0x000000000040048c, 0x000000000040048c): DW_OP_lit8,
DW_OP_stack_value)
DW_AT_GNU_locviews (0x0000000c)
GDB trace:
Reading symbols from opt...
(gdb) b 6
Breakpoint 1 at 0x40048c: file a.c, line 6.
(gdb) r
Starting program: /home/stepping/opt
Breakpoint 1, main () at a.c:7
7 a = l_144 != l_165;
(gdb) p l_144
$1 = 8 '\b'
I will add the executable file as an attachment.