<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/91542>91542</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Incorrect of debug informaiton of a structure variable compiled with "clang -g -O3"
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
edumoot
</td>
</tr>
</table>
<pre>
We compile the same source code from #83839, with different optimization level "-g -O3". After stepping in, we got the following information. The value of "a.f5" is not 7, but 50792199, and all the others are correct.
```
thread #1, name = 'bug_02_O3.out', stop reason = breakpoint 1.1
frame #0: 0x0000555555555141 bug_02_O3.out`main at bug_02.c:30:5
27 int main(void)
28 {
29 struct S0 a = fun_b();
-> 30 printf("%d\n",a.f5);
31 return 0;
32 }
33 //local_vars_info: [23, 24]
(lldb) fr v
(S0) a = (f0 = 2, f1 = -1, 0, f2 = 3, 0, f3 = 5, f4 = -6, f5 = 50792199)
(lldb) s
7
Process 3279674 stopped
* thread #1, name = 'bug_02_O3.out', stop reason = step in
frame #0: 0x0000555555555154 bug_02_O3.out`main at bug_02.c:31:5
28 {
29 struct S0 a = fun_b();
30 printf("%d\n",a.f5);
-> 31 return 0;
32 }
33 //local_vars_info: [23, 24]
34
(lldb) fr v
(S0) a = (f0 = 2, f1 = -1, 0, f2 = 3, 0, f3 = 5, f4 = -6, f5 = 50792199)
```
`cat bug_02.c`
```
#include <stdio.h>
struct S0 {
unsigned f0 : 7;
signed f1 : 2;
signed f2 : 29;
unsigned f3 : 20;
signed f4;
unsigned f5 : 26;
};
static int a = -1;
static int fun_a(int p)
{
return a;
}
static struct S0 fun_b(void)
{
int b = 2;
int *c = &a;
struct S0 d = {2,-1,3,5,-6,7};
(*c) = fun_a(b);
return d;
}
int main(void)
{
struct S0 a = fun_b();
printf("%d\n",a.f5);
return 0;
}
```
In LLVM 18.1.2 context, Reproduce with:
```
clang -g -O3 bug_02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