Open davidrohr opened 1 month ago
Strong +1 for differentiating the case of signed char
from char
. The current rules effectively discourage the effort of avoiding the abuse of signed char
to represent characters (instead of minimal-width signed integers), which is confusing. The type signed char
is better avoided to represent characters normally because it has no traditional, conventional or idiomatic meaning about characters (and char
should almost always be used instead). Each instance of using signed char
as characters (e.g. converted implicitly from or to char
values) may incur a question: is it really needed? This can derserve another dedicated check prior to the one here.
Additionally, the use of signed char
representing integers should better be the normal case, even if not that usual. Whitelisting this use by types in CharTypdefsToIgnore
is cumbersome and (argubly) not idiomatic, although there can be a few, say, FreeType's FT_Char
. Note that in FreeType FT_Char
is only used in its cache interface exactly for integers (not characters). FT_Char
and FT_Byte
here are confusing and inconsistent with other FreeTypes APIs.
Moreover, there can be support of well-known aliases of types like int8_t
as the exceptional cases by default, instead of tweaking CharTypdefsToIgnore
.
When running the following code through
clang-tidy
withbugprone-signed-char-misuse
it prints
I think we should not print this warning when
int8_t
is used. The warning is to catch character to int conversions, but whenint8_t
is used, the user normally wants explicitly a signed integer.In addition, I wonder actually why the check triggers on
Since here already I indicate that I want a signed char. AFAIK,
char
,signed char
,unsigned char
are 3 different types, and whetherchar
becomessigned char
orunsigned char
is implementation-defined. IMHO, the check should only trigger onchar
, i.e. only for