Given a base class B with a virtual function f, a derived class D and it's own implementation of f here are my scenarios:
B& b = *new D; b.f();
D& d = *new D; d.f();
Does the code in bullet 1 involve fetching f's address from vtable and then a jump? Does the code in listing 2 involve any vtable lookup at all?
I understand that these may be compiler dependent, and perhaps the standard will not specify the implementation details. In that case, I would be grateful if someone who understands how GCC or CLANG handles these cases provides for an explanation.
Thanks.
EDIT: Please cut-paste your assembler output; I am still not sure why in 2nd case there should be any lookup in vtable.