[lug] (OT) C++ ?, pointers to member functions

Tom Tromey tromey at redhat.com
Fri Aug 10 13:24:58 MDT 2001


>>>>> "Scott" == Scott A Herod <herod at interact-tv.com> writes:

Scott> To tie this with another C++ thread from a couple of weeks ago.
Scott> I guess that I would not expect objects built with different
Scott> "packing" to be used together successfully.  ( I probably
Scott> should check this with a simple test. )  Wouldn't changing how
Scott> the compiler segmented memory for the layout of objects make
Scott> vtables incompatable?

I doubt it, because I would imagine the vtable layout to be
independent of packing issues.  However, you could very well run into
other problems -- if the packing used in a derived class is different
from that in a base class, who knows what will happen?  In particular
I'm thinking that the implementations of virtual functions will differ
(will have the wrong offsets for fields, etc).  I'm sure the standard
doesn't address this, so it would be compiler dependent.  My advice
is: don't try it.  In fact, I generally advise against messing with
structure packing at all.

Tom



More information about the LUG mailing list