This is a compiler implementation detail. The reason you fall into this case is because there is MI in your code.
Think about how a computer accesses a member in ClassB using an offset to access a member. So, let's say you have two ints in class B, using the following statement to access the second member of int.
*((int*)pb + 1)
But if pb points to the beginning of aObject in your class, this will no longer work, so the compiler needs to create several versions of the assembly to access the same base of elements in the classβs inheritance structure and have time consuming.
This is why the compiler sets pb to not equal pa, which the above code will do, this is the easiest and most efficient way to implement it.
And that also explains why pa == pc , but not equal to pb .
source share