Hard
A virtual call through a pointer
Unlike the sibling question, there is no concrete local object here: speak() is called through a pointer, whose pointee the compiler has never seen. At -O2, is the call dispatched through the vtable?
main.cpp
struct Animal {
virtual void speak() const { }
};
struct Dog final : Animal {
void speak() const override { /* barks */ }
};
void call(Dog* d) {
d->speak(); // (1) called through a pointer the compiler cannot trace
}23 of 44 in Compilers