I know the attached code is horrible, but I inherited something like it at my place of work.
The call through the "Broken" function pointer works correctly (e.g. doesn't assert) on gcc 3.3 and gcc 3.4, but asserts on gcc 4.1.1 because the "this" pointer is incorrect. If "mem_fun" is changed to be "void (Base::*mem_fun) ()", (e.g. not varargs), the code works correctly. Again, I don't like this code and would never write code like this myself, its just something I've inherited and it breaks with the latest GCC so I wanted to let you know. Visual Studio 2005 won't even compile the code - it won't accept the function pointer casts. Testcase attached. -- Summary: Bad this pointer when calling thru pointer to varargs method Product: gcc Version: 4.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: gcc-bklyn at sneakemail dot com GCC build triplet: i486-linux-gnu GCC host triplet: i486-linux-gnu GCC target triplet: i486-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29243