Issue 107977
Summary [LLDB]The values ​​of array elements are incorrectly printed as 0
Labels new issue
Assignees
Reporter IOVOVHS
    This phenomenon is easy to happen, I am not sure if it is normal. At the O1 level, the values ​​of some elements of the array are changed to 0. In this example, except for [7], all other elements of the array are 0, but the print result in gdb is "optimized out", which seems to be clearer.Because there will be no misunderstanding.

``` 
197	        for (g_8[1][6] = 1; (g_8[1][6] >= 0); g_8[1][6] -= 1)
(gdb) p l_1684[7]
$1 = 2127969310
(gdb) p l_1684[0]
$2 = <optimized out>
(gdb) p l_1684[1]
$3 = <optimized out>
```

``` 
(lldb) b func_1
Breakpoint 1: where = random_819`main + 1 [inlined] func_1 at random_819.c:1326, address = 0x0000000000001141
(lldb) r
.......
(lldb) p l_1684[1]
(uint32_t) $0 = 0
(lldb) p l_1684[7]
(uint32_t) $1 = 2127969310
```
debug_info:
```
0x00000f46:       DW_TAG_variable
                    DW_AT_location      (DW_OP_piece 0x1c, DW_OP_constu 0x7ed63c1e, DW_OP_stack_value, DW_OP_piece 0x4)
                    DW_AT_abstract_origin       (0x0000063a "l_1684")
```

source code:
``` c
 169     struct S0 l_1648 = {-14};
 170     uint32_t l_1684[8] = {0x7ED63C1EL,0x7ED63C1EL,0x7ED63C1EL,0x7ED63C1EL,0x7ED63C1EL,0x7ED63C1EL,0x7ED63C1EL,0x7ED63C1EL};
 171     uint32_t l_1721 = 0UL;
........
 423                     l_1684[7]--;
 424                 }
```


clang version 19.0.0git (https://github.com/llvm/llvm-project.git b4ab52c8e71e819c13606de3500043eaa701e1ea)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/hzw/Downloads/llvm-project/build-release/bin

lldb version 19.0.0git (https://github.com/llvm/llvm-project.git revision b4ab52c8e71e819c13606de3500043eaa701e1ea)
  clang revision b4ab52c8e71e819c13606de3500043eaa701e1ea
  llvm revision b4ab52c8e71e819c13606de3500043eaa701e1ea
[random_819.zip](https://github.com/user-attachments/files/16941189/random_819.zip)

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to