>
>
>
V601. Suspicious implicit type casting.


V601. Suspicious implicit type casting.

The analyzer has detected an odd implicit type conversion. Such a type conversion might signal an error or carelessly written code.

Let's consider the first example.

std::string str;
bool bstr;
...
str = true;

Any programmer will be surprised on seeing an assignment of the 'true' value to a variable of the 'std::string' type. But this construct is quite permissible and working. The programmer just made a mistake here and wrote a wrong variable.

This is the correct code:

std::string str;
bool bstr;
...
bstr = true;

Consider the second example:

bool Ret(int *p)
{
  if (!p)
    return "p1";
  ...
}

The string literal "p1" turns into the 'true' variable and is returned from the function. It is a very odd code.

We cannot give you general recommendations on fixing such code, since every case must be considered individually.

This diagnostic is classified as:

You can look at examples of errors detected by the V601 diagnostic.