Hi, the testcase shows problem where cpp implicit alias is always inline and symtab_remove_unreachable_nodes removes the body of aliased function before inlininghappens. The real problem is that cgraph_state is set too early and not as the comment says after inlinig, but for release branch I think it is easier to sovle the problem by simply making the alias target reachable by hand.
Bootstrapped/regtested x86_64-linux, comitted to trunk. Let me know when it is OK for release brach. Honza Index: ChangeLog =================================================================== --- ChangeLog (revision 209458) +++ ChangeLog (working copy) @@ -1,3 +1,9 @@ +2014-04-16 Jan Hubicka <hubi...@ucw.cz> + + PR ipa/60854 + * ipa.c (symtab_remove_unreachable_nodes): Mark targets of + external aliases alive, too. + 2014-04-16 Andrew Pinski <apin...@cavium.com> * config/host-linux.c (TRY_EMPTY_VM_SPACE): Change aarch64 ilp32 Index: testsuite/ChangeLog =================================================================== --- testsuite/ChangeLog (revision 209450) +++ testsuite/ChangeLog (working copy) @@ -1,3 +1,8 @@ +2014-04-16 Jan Hubicka <hubi...@ucw.cz> + + PR ipa/60854 + * g++.dg/torture/pr60854.C: New testcase. + 2014-04-16 Catherine Moore <c...@codesourcery.com> * gcc.target/mips/umips-store16-2.c: New test. Index: ipa.c =================================================================== --- ipa.c (revision 209450) +++ ipa.c (working copy) @@ -415,7 +415,18 @@ symtab_remove_unreachable_nodes (bool be || !DECL_EXTERNAL (e->callee->decl) || e->callee->alias || before_inlining_p)) - pointer_set_insert (reachable, e->callee); + { + /* Be sure that we will not optimize out alias target + body. */ + if (DECL_EXTERNAL (e->callee->decl) + && e->callee->alias + && before_inlining_p) + { + pointer_set_insert (reachable, + cgraph_function_node (e->callee)); + } + pointer_set_insert (reachable, e->callee); + } enqueue_node (e->callee, &first, reachable); } Index: testsuite/g++.dg/torture/pr60854.C =================================================================== --- testsuite/g++.dg/torture/pr60854.C (revision 0) +++ testsuite/g++.dg/torture/pr60854.C (revision 0) @@ -0,0 +1,13 @@ +template <typename T> +class MyClass +{ +public: + __attribute__ ((__always_inline__)) inline MyClass () { ; } +}; + +extern template class MyClass<double>; + +void Func() +{ + MyClass<double> x; +}