This diagnostic rule is based on the software development guidelines developed by AUTOSAR (AUTomotive Open System ARchitecture).
Using the logical operators '!', '&&', and '||' with variables of a type other than 'bool' is pointless; it does not seem to be the intended behavior and may be a sign of a mistake. The programmer probably intended to use a bitwise operator ('&', '|', or '~').
Example of non-compliant code:
void Foo(int x, int y, int z)
{
if ((x + y) && z)
{
....
}
}
void Bar(int *x)
{
if (!x)
{
....
}
}
Fixed code:
void Foo(int x, int y, int z)
{
if ((x + y) & z)
{
....
}
}
void Foo(int x, int y, int z)
{
if ((x < y) && (y < z))
{
....
}
}
void Bar(int *x)
{
if (x == NULL)
{
....
}
}
This diagnostic rule is classified as:
|
Was this page helpful?
Your message has been sent. We will email you at
If you do not see the email in your inbox, please check if it is filtered to one of the following folders: