Hi, the ICE is caused by duplicate_thunk_for_node not copying DECL_ARGUMENTS in LTO mode because they are not streamed in. This is gcc-4.9 branch version of the fix, I will prepare mainline version shortly.
Bootstrapped/regtested x86_64-linux, comitted. PR lto/62026 * g++.dg/lto/pr62026.C: New testcase. * lto-streamer-out.c (lto_output): Handle thunks correctly. * cgraphclones.c (duplicate_thunk_for_node): Get thunk's arguments. Index: testsuite/g++.dg/lto/pr62026.C =================================================================== --- testsuite/g++.dg/lto/pr62026.C (revision 0) +++ testsuite/g++.dg/lto/pr62026.C (revision 0) @@ -0,0 +1,22 @@ +// { dg-lto-do link } +// { dg-lto-options {{-flto -O3 -r -nostdlib}} } +class C; +class F { + virtual C m_fn1(); +}; +class C { + public: + virtual int *m_fn3(int); +}; +class G : F, C { + int offsets; + int *m_fn3(int); +}; +C *a; +int *G::m_fn3(int) { + if (offsets) return 0; +} + +void fn1() { + for (;;) a->m_fn3(0); +} Index: lto-streamer-out.c =================================================================== --- lto-streamer-out.c (revision 215890) +++ lto-streamer-out.c (working copy) @@ -2077,7 +2077,10 @@ lto_output (void) #endif decl_state = lto_new_out_decl_state (); lto_push_out_decl_state (decl_state); - if (gimple_has_body_p (node->decl) || !flag_wpa) + if (gimple_has_body_p (node->decl) || !flag_wpa + /* Thunks have no body but they may be synthetized + at WPA time. */ + || DECL_ARGUMENTS (node->decl)) output_function (node); else copy_function (node); Index: cgraphclones.c =================================================================== --- cgraphclones.c (revision 215890) +++ cgraphclones.c (working copy) @@ -310,6 +310,11 @@ duplicate_thunk_for_node (cgraph_node *t if (thunk_of->thunk.thunk_p) node = duplicate_thunk_for_node (thunk_of, node); + /* We need to copy arguments, at LTO these mat not be read from function + section. */ + if (!DECL_ARGUMENTS (thunk->decl)) + cgraph_get_body (thunk); + struct cgraph_edge *cs; for (cs = node->callers; cs; cs = cs->next_caller) if (cs->caller->thunk.thunk_p