Sometimes I create an abstract class merely for implementation hiding, as an alternative to the pimpl idiom. If there is only one descendant and no public visibility outside the library that I'm building, why can't the linker remove the vtable?
I tried some experiments with clang and -Os. I added this to the constructor of one of my private impl classes:
printf("%p vs %p\n", this, &_first_member_field);
I always see an 8-byte difference between these two pointers, which I assume is the vtable pointer since I'm on a 64-bit arch. I also tried:
-no-rtti -flto=full -fvirtual-function-elimination -fstrict-vtable-pointers
But those 8 bytes never go away. Is this due to spec compliance?