
AMDG Simonson, Lucanus J <lucanus.j.simonson <at> intel.com> writes:
If I have Base and Derived types the compiler has to ensure correct execution when given the clearly standard compliant usage:
Derived object; object.do_something(); Base& baseRef = object; base.do_something_else(); Derived& derivedRef = static_cast<Derived&>(baseRef); derivedRef.do_yet_a_third_thing();
ergo it must implicitly support:
Base base; base.do_something_else(); Derived& derivedRef = static_cast<Derived&>(base); derivedRef.do_yet_a_third_thing();
provided that Derived does not modify Base by multiple inheritance, adding a member or a virtual pointer, because it can't prove that derivedRef is not an alias for the pointer to base because it could be that derivedRef is an alias for baseRef as part of the standard compliant usage.
*Non Sequitur.* Undefined behavior is generally not easily detectable statically. What I've been saying all along is that if do_yet_a_third_thing is a member of Derived then according to the standard if derivedRef is *not* an instance of derived /anything can happen/ In Christ, Steven Watanabe