Two pointers are smoothed when you can access the same object through them. Section 3.10 / 15 of the standard indicates when access to an object is valid.
If the program tries to access the stored value of the object through an l value other than one of the following types, the behavior is undefined:
- dynamic type of object
- cv-qualified version of the dynamic type of an object,
- a type that is a signed or unsigned type corresponding to a dynamic type of an object,
- a type that is a signed or unsigned type corresponding to the standard version of the dynamic type cv object,
- the aggregate or type of association, which includes one of the above types among its members (including, recursively, a member of a subordinate or contained association),
- a type that is (possibly cv-qualified) a base class type of a dynamic object type,
- a char or unsigned char type.
In your case *derived is either the l-value of the dynamic type of the object, or the type that is the type of the base class of the dynamic type of the object. *base has a type that is the type of the base class of the dynamic type of an object.
Therefore, you are allowed to access the object through derived and base , which makes the two pointers an alias.
avakar
source share