http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45721
--- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2010-11-11 12:28:42 UTC --- More complete testcase: --- file1.c ---- void baz(void) {} void *y = (void *)baz; int main () { return 0; } --- file2.c ---- static void bar(void) __attribute__ ((weakref("baz"))); void *x = (void *)bar; which still ICEs with a trivial patch I had (that fixed the original one). It shows that we somehow fail to mark baz as needed even though it is referenced by y. And of course we fail to mark it needed by the alias as well. One reason may be that we don't have a cgraph node for baz in file2.o (nor do we have one if declaring baz). OTOH when reading the cgraph node for baz it shows that it is !needed which is obviously wrong. ref_list of the cgraph node for baz is empty. The ref_list for y contains three times(!??): fn:baz/0 (addr) fn:baz/0 (addr) fn:baz/0 (addr) then 2nd and 3rd come from #5 0x0000000000d075f0 in cgraph_process_new_functions () at /space/rguenther/src/svn/trunk/gcc/cgraphunit.c:219 219 varpool_analyze_pending_decls (); (gdb) #6 0x00000000008fae86 in execute_one_pass (pass=0x1722900) at /space/rguenther/src/svn/trunk/gcc/passes.c:1596 1596 cgraph_process_new_functions (); as somehow the decl stays in pending state? It does because Old value = (struct varpool_node *) 0x0 New value = (struct varpool_node *) 0x7ffff5cf8138 varpool_enqueue_needed_node (node=0x7ffff5cf8138) at /space/rguenther/src/svn/trunk/gcc/varpool.c:303 303 notice_global_symbol (node->decl); (gdb) up #1 0x0000000000d7367f in varpool_mark_needed_node (node=0x7ffff5cf8138) at /space/rguenther/src/svn/trunk/gcc/varpool.c:315 315 varpool_enqueue_needed_node (node); re-queues it. Why if it is already analyzed (and why did it become !needed again? Should varpool_analyze_pending_decls not re-analyze analyzed nodes?) These are, of course, just unrelated problems. Still for some reason the cgraph node is not needed: Breakpoint 1, fancy_abort ( file=0x113abc8 "/space/rguenther/src/svn/trunk/gcc/ipa.c", line=783, function=0x113ae20 "function_and_variable_visibility") at /space/rguenther/src/svn/trunk/gcc/diagnostic.c:881 881 internal_error ("in %s, at %s:%d", function, trim_filename (file), line); (gdb) up #1 0x0000000000c82296 in function_and_variable_visibility ( whole_program=0 '\000') at /space/rguenther/src/svn/trunk/gcc/ipa.c:782 warning: Source file is more recent than executable. 782 gcc_assert (node->needed); (gdb) p node->ref_list $11 = {references = 0x0, refering = 0x17739e0} (gdb) p node->ref_list->refering $12 = (VEC_ipa_ref_ptr_heap *) 0x17739e0 (gdb) p node->ref_list->refering->base.vec[0]->refering.varpool_node->needed $13 = 1 but it has a referer that is needed. Honza - please investigate this - I'm lost in the maze.