<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/86989>86989</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[LLDB] Incorrect type promotion of an unscoped enum with the default type in arithmetic operations
</td>
</tr>
<tr>
<th>Labels</th>
<td>
lldb
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
kuilpd
</td>
</tr>
</table>
<pre>
When using an enum value in an arithmetic operation LLDB promotes the resulting type to `unsigned int`, and not to the default underlying type `int`.
Source code with 2 variables with the results from a compiler:
```
enum UnscopedEnum { Zero, One };
int main() {
auto enum_one = UnscopedEnum::One;
auto negated = -enum_one;
auto added = enum_one + 1;
return 0;
}
```
LLDB log:
```
(lldb) expr negated
(int) $0 = -1
(lldb) expr added
(int) $1 = 2
(lldb) expr -enum_one
(unsigned int) $2 = 4294967295
(lldb) expr enum_one + 1
(unsigned int) $3 = 2
```
If the enum type is explicitly specified `enum UnscopedEnum : int`, then the promotion works correctly.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8VF1r6zgQ_TXyy9Agy_HXgx-azQYKhT4sy8K-LLI1jrWVJaOP9ubfXyTnqyX3QnCQNOfozNHMcOfkUSN2pNyRcp_x4Cdju_cg1SKy3ohT98-EGoKT-ghcA-owwwdXAUHquMGt9NOMXg5gFrTcS6Ph9XW_g8Wa2Xh04CcEiy4oH0n8aUHwBkhFg063C5Dak4oS9gdwLUAbHwMiTODIg_IQtECrTlc8qeiK2RC6J_R5_f5lgh0QBiMQPqWfgMEHt5L3Ct26cZPiYLRmBg6DmRep0JLizBKVrL-0TBn_rd1gFhR_xgWpd_AvWhP1vmkEUu9JsbsXIrWHmUtNWENYGwHrPvDgTfLwPxOBxf4Lc5RQPL9pvNLBitB45B5FAjxd4N-DuBDnkNsFbAf5XZxFH6wGepNb7x8mvX7TMypz_JU1hDVKiT6miD8We5F5PYxPFNNnW7pKzx_jkvIHqDyh2L2k79CbG5fjL0W18rDEs2Xttq1q1paPqb659hu-4ouuR869jKnUUu2kgpUuXqLkIL06gVtwkKOMz1XRBwVWPN-1hI8NGNnWhor99Wnsu4PBWIuDV6dzE2SiK0RbtDzDLq_zvCoZa2k2ddVYc1qWQuRj25db2g60FrnoBa16VlZVJjtG2ZYWrMmbssnpRtSsYU1dNaJqKhx7sqU4c6k2Sn3MG2OPmXQuYNdUbdNmiveoXJohjK2esjhNbBfDn_pwdGRLlXTe3Qi89CrNnVhlpNzDiz4ntDp2y9aMcdCEs0OrqdduvkyI1eXH88hlwapu8n5xsZTZgbDDUfop9JvBzIQdoqjz39Nizf84eMIOKUVH2CFl-TMAAP__Z3eTNQ">