﻿# V3545\. AUTOSAR\. Operands of the logical '&&' or the '\|\|' operators, the '\!' operator should have 'bool' type\.

This diagnostic rule is based on the software development guidelines developed by [AUTOSAR](https://www.autosar.org/) \(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:

```cpp
void Foo(int x, int y, int z)
{
  if ((x + y) && z)
  {
    ....
  }
}

void Bar(int *x)
{
  if (!x)
  {
    ....
  }
}
```

Fixed code:

```cpp
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)
  {
    ....
  }
}
```