Issue 86989
Summary [LLDB] Incorrect type promotion of an unscoped enum with the default type in arithmetic operations
Labels lldb
Assignees
Reporter kuilpd
    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.

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to