------- Comment #3 from jakub at gcc dot gnu dot org 2008-10-21 11:46 ------- With -fno-toplevel-reorder this generated foobar variable in .rodata already in 4.3, maybe earlier. The interesting code is in decide_is_variable_needed: /* When not reordering top level variables, we have to assume that we are going to keep everything. */ if (flag_toplevel_reorder) return false;
/* We want to emit COMDAT variables only when absolutely necessary. */ if (DECL_COMDAT (decl)) return false; return true; Is that true even with unit-at-a-time that we have to assume all vars are potentially used? After all, we should know all the variables, their initializers and functions at this point. If we can't change this, then I guess either the testcase should be passed -ftoplevel-reorder, or matching foobar:(c=i|S) . Honza? -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36668