rspec/rules/S5286/cfamily/rule.adoc

31 lines
521 B
Plaintext

== Why is this an issue?
Implicit casts which do not make sense are likely to be programming errors.
The rule reports an issue for the following implicit casts:
* Boolean to pointer
* Float to boolean
* ``++nullptr++`` constant to integer
=== Noncompliant code example
[source,cpp]
----
float f();
bool test() {
int* j = false; // Noncompliant
bool b = f(); // Noncompliant
if (b) {
return j; // Compliant, pointer to bool
} else {
return nullptr; // Noncompliant, just return false
}
}
----