It is undefined behavior, so you really should be very scared.
It might happen to apparently do something (on your implementation of C++), because the getData
function is not virtual and don't use any member of B
. So the generated code does not dereference the null pointer.