Avoid warning when char is unsigned#1343
Conversation
|
Thanks for the PR but the existing function signatures look correct to me so it would be great if you could explain the problem and solution. Instead of this change, would a simple |
|
On most ARM 64‑bit ABIs char is signed by default. When the parameter type is char, the expression
So the warning is not about a bug in the logic; it is just telling that the first sub‑expression does nothing. If you want to keep the interface with |
4df8a8b to
c371954
Compare
I think there's a mixup in your explanation and you meant that it's unsigned by default. Thank you — I understand the problem now. Example of a warning with GCC (targeting aarch64): We can also get this warning if signedness is specified to be unsigned on the command line ( The warning does not show up with only |
c371954 to
c015046
Compare
SteffenL
left a comment
There was a problem hiding this comment.
Looks good to me ― thank you!
char's signedness is implementation‑defined.
https://en.cppreference.com/w/cpp/language/types.html -> Character types ->
The signedness of char depends on the compiler and the target platform: the defaults for ARM and PowerPC are typically unsigned, the defaults for x86 and x64 are typically signed.C++17/20 standard: 6.9.1:
It is implementation-defined whether a char object can hold negative values.