http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51726
Richard Guenther <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2012-01-02 Ever Confirmed|0 |1 --- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-01-02 11:19:41 UTC --- It's a target bug - the target should ignore the attribute on extern declarations. case VAR_DECL: if (lookup_attribute ("selectany", DECL_ATTRIBUTES (decl))) { if (DECL_INITIAL (decl) /* If an object is initialized with a ctor, the static initialization and destruction code for it is present in each unit defining the object. The code that calls the ctor is protected by a link-once guard variable, so that the object still has link-once semantics, */ || TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (decl))) make_decl_one_only (decl, DECL_ASSEMBLER_NAME (decl)); else error ("%q+D:'selectany' attribute applies only to " "initialized objects", decl); } thus, restrict processing to !DECL_EXTERNAL