Compiling and executing this code: --------------------------------- #include <iostream> using namespace std; void *p; struct vbase { int a; virtual vbase* me() = 0; void set_p() { p = me(); }; }; struct derived : virtual vbase { int b; derived* me() { cout << "derived::me() = " << this << endl; return this; }; }; int main() { derived t; t.set_p(); cout << "p = " << p << endl; }; --------------------------------- produce the strange results, the output is: --------------------------------- derived::me() = 0xbff41ab0 p = 0xbff41ab8 --------------------------------- It doesn't metter is me() a pure virtual function or has a body in 'vbase' class. Small changes in code, any of these: 1) declaring the return type of me() as void* 2) commenting data member 'int a' in 'vbase' class 3) making 'vbase' non virtual base of 'derived' give the right result: saved 'this' in 'p' is equal to 'this' of derived class. Sorry, don't know how to summarize the problem, is it a bug or I misunderstood some c++ subtle points...
conversion from derived* to vbase* involves adjusting a pointer in the context of vbase::set_p the value returned from me() is converted to vbase* so the pointer is adjusted try changing derived::me() to this: int b; derived* me() { cout << "derived::me() = " << this << endl; cout << "derived::me() as vbase = " << (vbase*)this << endl; return this; }; you will see that the value is different, and the second value is the one assigned to ::p