This is completely normal and this is not a problem. What you do in this example is sometimes called "aliasing" - when two arguments actually refer to the same object.
Consider an even simpler case in simple C:
void foo(int* a, const int* b) { *a += *b; }
This function takes two pointers to int s and adds the second to the first. And of course, this code is absolutely right for using my foo function.
int x = 10; foo(&x, &x);
If you do not like this behavior in this case, it is best to add validation to your method, for example
void A::method(A& otherA) const { if (this == &otherA) { } else { } }
source share