Hi When GCC generates virtual methods for objects with multiple inheritance, it creates special "thunk" functions that adjust this pointer and jump to an original method.
When a member function returns a structure, the first argument is a pointer where return structure should be placed, the second argument is "this" pointer and additional arguments are arguments of the member function. When using regparm 2 or 3, the first argument (ptr to return structure) is in EAX, the second argument (this) is in EDX and additional arguments are in ECX and on the stack. The thunking function is generated incorrectly and always tries to adjust EAX, causing corruption to this pointer and to the return value. Similarly, when using fastcall convention, the pointer to return structure is in ECX and this is in EDX, however thunking function adjusts ECX. This bug is present in all GCC releases. -- Summary: incorrect code generated on i386 for C++ multiple inheritance, large return structures and regparm or fastcall calling conventions Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: mikulas at artax dot karlin dot mff dot cuni dot cz GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35504