INT-use-signed-as-unsigned-pos
In this section:
Synopsis
A negative signed integer is implicitly cast to an unsigned integer.
Enabled by default
No
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(int c) {
int a = 5;
if (c) {
a=-10;
}
unsigned int b = a;
}
The following code example passes the check and will not give a warning about this issue:
void example(int c) {
int a = 10;
if (c) {
a=5;
}
unsigned int b = a;
}