<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/62118>62118</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang] Clang generate incompatible types in DWARF expressions.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
jwnhy
</td>
</tr>
</table>
<pre>
Given the following code:
#include "stdint.h"
int a, b = 9067;
volatile uint16_t *c = (volatile uint16_t*)&b;
int *d = &a;
int func_1() {
uint16_t e[7][2][8];
uint32_t f = 37455;
int32_t l_146;
a = 0;
l_146 = *c * f;
*d = e[3][1][5];
return l_146;
}
int main() { func_1(); return 0; }
Compiled with clang 15.0.7 and -O1 -g.
For l_146, the following DWARF is generated.
(gdb) info addr l_146
Symbol "l_146" is multi-location:
Range 0x555555554674-0x55555555467b: a complex DWARF expression:
0: DW_OP_breg0 0 [$rax]
2: DW_OP_constu 65535
6: DW_OP_and
7: DW_OP_convert<DW_ATE_unsigned_16 [0x27]>
12: DW_OP_convert<DW_ATE_unsigned_32 [0x2b]>
17: DW_OP_constu 37455
21: DW_OP_mul
22: DW_OP_stack_value
However, this DWARF expression is actually invalid, as `DW_OP_mul` expects two operands to have either the same type or generic type as stated in the standard.
> Operations other than DW_OP_const_type push a value with the generic type
while `DW_OP_convert` converts type to unsigned, but explicit unsigned is not compatible with generic (despite it's a really werid standard......)...
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVctyqzgQ_Rp502UKJF5eeOHE8cwuU3emKktKoDbojpBcSNjJ309JYIOTzbCwDKf79ENHLW6tbDXinmQvJDtu-Og6M-x_33T3tamN-Nr_Ia-owXUIZ6OUuUndQmMEEnYg8ZHEB0KZ1I0aBQKh1DohtYs6QukES-2AE_oKNRB2hF2cF4S9TNjVKO6kQhildkleOSD00AQ7QssfKKEHQneE5vWDwbMTehCzT86fkPOomyoht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