Is there any time or space penalty from inheriting virtually when not needed? For example, consider (x->y means "y inherits from x") A -virtual-> B -> C, where there are no other classes in the program. How does this compare to A -> B -> C?
I can make guesses on my own. I don't need to ask anyone to know that it might have a cost. I want to know if it actually has a cost.
If there are virtual functions there will be a need for virtual tables which increases both to some degree.
Virtual functions are orthogonal to virtual inheritance. You can have neither, both, or just one of the two.
Like the rest of C++ if you don't need a feature don't use it and you will probably save on one or the other or both.
I'm asking because in my case I need to generate class definitions from a high-level description, and it turns out that deciding whether a particular inheritance should be virtual or not from an inheritance graph (a DAG) is non-trivial. If the compiler generates code and memory layouts in such a way that inheriting virtually when not needed has basically no cost then I can just always inherit virtually and forget about the problem.