------- Comment #2 from dleska at gmail dot com 2007-09-09 06:47 ------- (In reply to comment #1) > VS seems to dispatch to some other function.
Yep - if the function is virtual, VS generates a stub that does the vtable lookup. However for non virtual function the call is direct - which is much faster than what gcc does. Note that if I replace the first line of my example with 'class SomeClass;' - gcc and VS generate comparable code. However when the class is defined at the point of the call and does not use multiple/virtual inheritance, VS generates significantly faster calls (at least for non-virtual functions). Is this optimisation not possible in gcc? -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33358