https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65236
Jan Hubicka <hubicka at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2015-02-27 CC| |hubicka at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #4 from Jan Hubicka <hubicka at gcc dot gnu.org> --- One bug with thunks I am aware of is demonstrated by the following testcase: struct A { A() {ptr=&b;} A(const A &a) {ptr = &b;} void test() { if (ptr != &b) __builtin_abort ();} int b; int *ptr; }; A test1(A a) { a.test(); return a; } A test2(A a) { a.test(); return a; } __attribute__ ((noinline)) void test_me (A (*t)(A)) { struct A a, b=t(a); b.test (); } int main() { test_me (test1); test_me (test2); return 0; } we turn test2 into a thunk but after inlining the thunk we end up with producing extrra copy of return value A.