EGCS: pointer to member functions.

Martin v. Loewis
Wed Jun 30 15:43:00 GMT 1999

> Why is there so much overhead in calling a function via a pointer as
> apposed to calling it directly ?

Because it's so complicated :-)

> I'm not sure why there are comparison statements (cmpwi).

Two things need to be done:
a) the this-pointer might need to be adjusted, and
b) the call might be a virtual function call

In case of a non-virtual function, part of the member pointer points
to the function. The other part tells that it is a non-virtual

In case of a virtual function, the pointer contains the index into the
virtual method table. The cmpwi is an if-statement determining whether
to do a virtual or a non-virtual call.

Hope this helps,

More information about the Gcc mailing list