V601. An odd 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.

Bugs Found

Checked Projects
Collected Errors
14 469
This website uses cookies and other technology to provide you a more personalized experience. By continuing the view of our web-pages you accept the terms of using these files. If you don't want your personal data to be processed, please, leave this site. Learn More →