Pointers-to-members

Jason Merrill jason at cygnus.com
Wed Feb 23 18:51:45 UTC 2000


>>>>> Mark Mitchell <mark at codesourcery.com> writes:

 >   o A pointer-to-derived can be converted to a pointer-to-base.  This
 >     will normally increase the `this' pointer.  The standard is a
 >     little unclear here, but I think it wants to say that this is
 >     illegal precisely in the cases where the offset would go negative:

 >       [expr.static.cast]

 >       If class B contains the original member, or is a base or derived
 >       class of the class containing the original member, the resulting
 >       pointer to member points to the original member.  Otherwise, the
 >       result of the cast is undefined.

I don't see anything in the quoted text that would suggest that this is
illegal (or even undefined).  The standard then goes on to say explicitly
that it's OK to cast to a base that doesn't contain the member:

[Note: although class B need not contain the original member, the dynamic
type of the object on which the pointer to member is dereferenced must
contain the original member.]

Jason




More information about the cxx-abi-dev mailing list