http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57945
--- Comment #5 from Jan Hubicka <hubicka at ucw dot cz> --- > Even better something that uses it and that even declares the original: > extern int j; > static int i __attribute__((weakref("j"))); > > int > foo (void) > { > return &i ? i : 0; > } > > This ICEs with cc1plus even at -O2, since r199971. The problem is that > node->alias_target is IDENTIFIER_NODE, some places cope with it being > IDENTIFIER_NODE (in fact, I don't see where it would become something > different), but some places just blindly assume it must be a DECL_P. It is IDENTIFIER_NODE until it is "resolved" into a target symbol that is a decl (and one gets proper reference edge in symbol table). For normal aliases the identifier_node gets turned into a decl after compilation unit is finalized (via resolve_alias). External weakrefs may be never resolved...