| Issue |
108943
|
| Summary |
clang-tidy bugprone-signed-char-misuse triggers on int8_t to int cast
|
| Labels |
clang-tidy
|
| Assignees |
|
| Reporter |
davidrohr
|
When running the following code through `clang-tidy` with `bugprone-signed-char-misuse`
```
int8_t y = 0;
int32_t x = y;
```
it prints
```
[warning: 'signed char' to 'int32_t' (aka 'int') conversion; consider casting to 'unsigned char' first. [bugprone-signed-char-misuse]](_javascript_:;)
7 | int32_t x = y;
```
I think we should not print this warning when `int8_t` is used. The warning is to catch character to int conversions, but when `int8_t` is used, the user normally wants explicitly a signed integer.
In addition, I wonder actually why the check triggers on
```
signed char y = 0;
int32_t x = y;
```
Since here already I indicate that I want a signed char. AFAIK, `char`, `signed char`, `unsigned char` are 3 different types, and whether `char` becomes `signed char` or `unsigned char` is implementation-defined.
IMHO, the check should only trigger on `char`, i.e. only for
```
char y = 0;
int32_t x = y;
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs