Some signed to unsigned conversions may lead to implementation-defined behavior. This behavior may not be consistent with developer
expectations.
If you need to mix signed and unsigned types, you should make your intent explicit by using explicit casts and avoiding implicit casts.
This rule will detect implicit conversions that change the signedness.
Noncompliant code example
void f(int a) {
unsigned int b = a; // Noncompliant
int c = (a > 0) ? a : b; // Noncompliant
if (a > b) { // Noncompliant
// ...
}
}
Compliant solution
void f(int a) {
unsigned int b = static_cast<unsigned int>(a); // Compliant
}