I am asking the question again because the only other question that is like this is approaching 10 years old, and contains incorrect information about expressions involving base class subobjects:
[defns.dynamic.type] defines the dynamic type of a glvalue as:
type of the most derived object to which the glvalue refers
A glvalue only refers to at most one object, and since "most derived object" as defined by [intro.object] p6 essentially is:
A complete object, a data member, or an array element of class type, or, an object of a non-class type is called a most derived object.
If the glvalue does not refer to a most derived object, then would the dynamic type be undefined?
Also, I know the intended effect of dynamic type of an expression is: for a glvalue expression E
that refers to an object of type B
, which is a base class subobject of an object of type D
, where B
is a base class of D
, to get the type D
from E
, however, I do not see how the current wording accomplishes that, or even needs to, since references/pointers of base class type bound to derived class type will always refer to the base class subobject. As far as I can tell, a case where the type of the expression and the type of the object that it refers to would never occur.