Hopefully this isn\'t too specialized of a question for StackOverflow: if it is and could be migrated elsewhere let me know...
Many moons ago, I wrote a und
Is there anything in Standard C++ which would prevent a compiler from performing such a transformation?
Not if you're sure the observable behavior is unchanged - that's the "as-if rule" which is Standard section 1.9.
But this might make proving that your transformation is correct pretty difficult: 12.7/4:
When a virtual function is called directly or indirectly from a constructor (including the mem-initializer or brace-or-equal-initializer for a non-static data member) or from a destructor, and the object to which the call applies is the object under construction or destruction, the function called is the one defined in the constructor or destructor's own class or in one of its bases, but not a function overriding it in a class derived from the constructor or destructor's own class, or overriding it in one of the other base classes of the most derived object.
So if the destructor Foo::~Foo() happens to directly or indirectly call C::quack() on an object c, where c._f points at the object being destroyed, you need to call Foo::bark(), even if _f was a FooA when you constructed object c.