The C++ Standard define the concept "dynamic type" of a glvalue as follows:
dynamic type
<glvalue> type of the most derived object (1.8) to which the glvalue denoted by a glvalue expression refers [Example: if a pointer (8.3.1) p whose static type is “pointer to class B” is pointing to an object of class D, derived from B (Clause 10), the dynamic type of the expression *p is “D.” References (8.3.2) are treated similarly. —end example ]
How is this definition interpreted if what the glvalue refers to is not the most derived object? Does it mean "type of the most derived object that contains the object to which the glvalue denoted by a glvalue expression refers"?
Another puzzle is about the 4th paragraph in 5.7 of the C++ Standard:
... If the pointer operand points to an element of an array object, ...
I want to ask whether this condition holds if the pointer operand points to a subobject of an element of an array object. As an example, if it does not hold, then the behavior in the following code is undefined, right?
D d[10];
B *p = d; //B is a base class of D
p += 2; //undefined behavior?