Our website uses cookies to enhance your browsing experience.
Accept
to the top
>
>
>
V6032. It is odd that the body of...
menu mobile close menu
Additional information
toggle menu Contents

V6032. It is odd that the body of 'Foo_1' function is fully equivalent to the body of 'Foo_2' function.

May 11 2018

The analyzer has detected two methods with identical implementations. Although having two identical functions is not an error, they should still be reviewed.

The diagnostic rule detects the following error types:

class Point
{
  ....
  int GetX() { return mX; }
  int GetY() { return mX; }
};

A typo causes two logically different methods to perform the same actions. The fixed code:

int GetX() { return mX; }
int GetY() { return mY; }

In the example, the identical bodies of the GetX() and GetY() methods indicate an error. However, issuing warnings for all identical methods could result in many false positives. Therefore, the analyzer has a number of exceptions where a warning about identical method bodies is not required.

Some examples of exceptions:

  • the analyzer does not report about identical methods' bodies if they do not use variables except for arguments. For example: bool IsXYZ() { return true; };
  • methods with identical bodies are repeated more than twice;
  • methods' bodies consist of only the throw() statement;
  • and so on.

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