views:

42

answers:

2

I've heard that recent versions of gcc are very good at converting calls through function pointers to direct calls. However, I can't find anything about it on the web or the quick look through gcc's source code. Does anyone know if this is actually true and if so, what algorithm does it use to do this?

A: 

It's just a form of value propagation. If I can prove that object pointer p (to a virtual calss) always points to an object of a particular concrete class, then I can call that class's member functions directly. If not, I have to go through the vtable.

Anonymous
+1  A: 

You might find this article interesting. It's dated 2005, and I'm not sure if that's 'recent' enough, but it deals with the subject comprehensively:

http://www.codeproject.com/KB/cpp/FastDelegate.aspx