-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Open
Labels
Description
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;
FrankHB and Shaidak