The following valid code snippet fails to compile on mainline when compiled with "-O": ======================================= struct A { virtual A* foo(); }; struct B : virtual A { virtual B* foo() { return 0; } }; B b; ======================================= bug.cc:11: error: 'B* *.LTHUNK1()' aliased to undefined symbol '_ZTch0_v0_n32_N1B3fooEv'
This bug has hit me as well. This blocks the popular "clone" idiom when using virtual base classes (which I use a lot of). Might this change be a result of the indirect inlining patch?
This looks like a fallout from the unit-at-a-time changes. The testcase works for me with -O -fno-toplevel-reorder. Honza, can you have a look here?
The problem is that cgraph_node_for_asm assumes that once it has been called once, no new cgraph nodes will be created. But that's not true, at least C++ lang_hooks.callgraph.emit_associated_thunks (decl) adds new cgraph nodes (for the thunks). So, either cgraph_create_node should keep populating assembler_name_hash once that hash table is created, or there should be a cgraph function which can be called for the late cgraph nodes to get registered into the assembler_name_hash.
Created attachment 16184 [details] gcc44-pr37095.patch Patch I'm going to bootstrap now.
Fixed.
Subject: Bug 37095 Author: jakub Date: Tue Sep 2 10:33:46 2008 New Revision: 139887 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=139887 Log: PR tree-optimization/37095 * cgraph.c (cgraph_node): When creating new cgraph node after assembler_name_hash has been populated, record it in the hash table. * g++.dg/inherit/thunk9.C: New test. Added: trunk/gcc/testsuite/g++.dg/inherit/thunk9.C Modified: trunk/gcc/ChangeLog trunk/gcc/cgraph.c trunk/gcc/testsuite/ChangeLog
*** Bug 37167 has been marked as a duplicate of this bug. ***