Why does Eclipse-CDT say self-starting is an error?

I did a unit test in eclipse g ++ using google test. I had an error when I tried to perform a unit test self-binding check in a class that I developed.

as usual, the overload is pretty standard and looks like this:

CLASS operator=(const CLASS& rhs);

and when I tried to get this in the test:

CLASS A;
A = A;   //compile error here, saying self assignment to itself. have no clue why, though.

I wonder if there is a specific method for a self-study test. Thank.

FYI, below is a snapshot of the error

enter image description here

+4
source share
1 answer

Assignment operator x = x; is not, of course, a mistake in C ++ and here you have no compiler error.

IDE , , , . , .

, , , C/++. , Eclipse CDT Code Analyzer (Codan), .

Codan , . .

:

  • 1). .
  • 2). , .

2):

  • C/++
  • : -
    • , ....
+14

Source: https://habr.com/ru/post/1541331/


All Articles