INT-use-signed-as-unsigned
In this section:
Synopsis
A negative signed integer is implicitly cast to an unsigned integer.
Enabled by default
Yes
Severity/Certainty
Medium/Medium

Full description
A negative signed integer is implicitly cast to an unsigned integer. The result of this cast will be a large integer, and using this value might result in unexpected behavior.
Coding standards
- CWE 195
Signed to Unsigned Conversion Error
Code examples
The following code example fails the check and will give a warning:
void example(void) {
int a = -10;
unsigned int b = a;
}
The following code example passes the check and will not give a warning about this issue:
void example(void) {
int a = 10;
unsigned int b = a;
}