Issue 145651
Summary [clang-tidy] `bugprone-signed-char-misuse` gives false positives in C23 for enum with signed char type
Labels clang-tidy
Assignees
Reporter bjosv
    When running `bugprone-signed-char-misuse` on C23 code that uses [enums](https://en.cppreference.com/w/c/language/enum.html
) with a fixed underlying type of `signed char` we get warnings.
```
enum e : signed char {
    E_M128 = -128,
};

enum e state = E_M128;
```
A full example:
https://godbolt.org/z/vGTj966TY

The checker gets that the RHS EnumConstant is a `signed char` but don't use the fact that LHS is of type signed char, giving a warning.

The RHS seems to give the AST
`ImplicitCastExpr <col:13> 'e_t':'enum e' <IntegralCast>`
but we have not found anything in the standard that motivates the warning and we believe it's a false positive.


_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to