| Issue |
204520
|
| Summary |
[lldb] lldb widens narrow typed operands when evaluating DW_OP_plus_uconst
|
| Labels |
|
| Assignees |
|
| Reporter |
firmiana402
|
For typed DWARF values, `DW_OP_plus_uconst` should add the ULEB immediate in the same explicit base type as the popped operand.
LLDB currently appears to forward this operation to `uint64` `Scalar` arithmetic, which widens narrow typed integers before performing the addition. That destroys the wraparound semantics of the original DWARF base type.
## Minimal Case
```text
DW_OP_constu 0xffffffffffffffff
DW_OP_convert <unsigned char>
DW_OP_plus_uconst 1
DW_OP_constu 7
DW_OP_convert <unsigned char>
DW_OP_shr
...
```
This should be a strict zero-carry prefix:
- converting all-ones to `unsigned char` yields `0xff`
- `0xff + 1` in `unsigned char` should wrap to `0`
- `0 >> 7` is `0`
So the whole _expression_ should still evaluate to `0`.
Instead, LLDB widens the `unsigned char` operand to a `uint64` before the addition, so `0xff + 1` becomes `0x100` instead of wrapping to `0`, and the later right-shift therefore produces a final result of `1` instead of `0`.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs