| Issue |
109722
|
| Summary |
Debug information for loop control variable initialization is incorrect in binary compiled with "-O0"
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
edumoot
|
The variable `i_1` at line 8 is incorrectly initialized to `23` instead of `0`. This issue can be reproduced using LLVM versions 18.1.8, 17.0.6, and 16.0.3. Godbolt link is [here](https://godbolt.org/z/rETvsb9cT)
```
clang -g -O0 func.c driver.c -o test_O0.out
lldb test_O0.out
(lldb) b func.c:8
(lldb) r
[...]
* thread #1, name = 'test_O0.out', stop reason = breakpoint 1.1
frame #0: 0x0000555555555156 test_O0.out`test at func.c:8:32
5 void test() {
6 if (var_5){
7 for (unsigned int i_0 = 0; i_0 < 23; i_0 += 3)
-> 8 for (long long int i_1 = 0; i_1 < 23; i_1 += 4)
9 arr_7 [i_0] [i_1] = var_0 && arr_1 [5U];
10 }
11 }
(lldb) p i_1
(long long) 23
```
GDB also exhibits this behavior.
```
$gdb test_O0.out
GNU gdb (Ubuntu 15.0.50.20240403-0ubuntu1) 15.0.50.20240403-git
[...]
(gdb) b func.c:8
(gdb) r
[...]
Breakpoint 1, test () at func.c:8
8 for (long long int i_1 = 0; i_1 < 23; i_1 += 4)
(gdb) p i_1
$1 = 23
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs