https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96765
Jason Merrill <jason at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jason at gcc dot gnu.org --- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> --- Hmm, is the cast undefined, actually? I thought you were right, but now can't find any wording to that effect. I see [expr.static.cast] If the prvalue of type “pointer to cv1 B” points to a B that is actually a base class subobject of an object of type D, the resulting pointer points to the enclosing object of type D. Otherwise, the behavior is undefined. But this B is a base of a D. Then [class.cdtor] For an object with a non-trivial constructor, referring to any non-static member or base class of the object before the constructor begins execution results in undefined behavior. but D() has begun execution. Then [class.cdtor] During the construction of an object, if the value of the object or any of its subobjects is accessed through a glvalue that is not obtained, directly or indirectly, from the constructor’s this pointer, the value of the object or subobject thus obtained is unspecified. but 'this' in the Base ctor seems to count as obtained indirectly from 'this' in the Derived ctor. Then [class.cdtor] paragraph 4 talks about virtual functions, which this is not. What rule makes this undefined?