Pointers-to-members
Mark Mitchell
mark at codesourcery.com
Mon Feb 21 21:51:28 UTC 2000
Following up on my own suggestion:
The ABI document says that a NULL pointer-to-member function has
`ptr == 0'. It does, not, however say whether or not a NULL
pointer-to-member function also has `adj == 0'.
I believe that this should be specified as well so that code generated
to do comparison of pointers to members (of the same type) looks like:
p1->ptr == p2->ptr && p1->adj == p2->adj
and not:
p1->ptr == p2->ptr && (!p1->ptr || (p1->adj == p2->adj))
So, I would say:
If the pointer-to-member is NULL, both fields are zero. (Note:
there are no non-NULL pointers-to-members for which the `ptr'
field is non-zero.)
It's occurred to me that this imposes some overhead on casting
pointers-to-members around: now when you convert from a base pointer
to member to a derived version (or vice versa), you can't just adjust
the `adj' member willy-nilly; instead, you have to check first whether
or not the pointer is NULL.
So, I'm not sure any more which scheme is preferable -- but we
definitely need to say clearly which we want.
--
Mark Mitchell mark at codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
More information about the cxx-abi-dev
mailing list