static inline __attribute__((always_inline)) void bar (void) { addr:; static const unsigned long b __attribute__((__used__)) __attribute__((section("btable"))) = (unsigned long) &&addr; asm ("" : : "m" (b)); }
void foo (void) { bar (); } generates at -O and higher a reference to undefined local label (and has one unused different label). If the body of bar is instead copied into foo () and the call removed, it works fine. I think this is related to the http://gcc.gnu.org/ml/gcc-patches/2005-06/msg01850.html changes, not sure why isn't the local var remapped in: /* Add local vars in this inlined callee to caller. */ t_step = id->src_cfun->unexpanded_var_list; for (; t_step; t_step = TREE_CHAIN (t_step)) { var = TREE_VALUE (t_step); if (TREE_STATIC (var) && !TREE_ASM_WRITTEN (var)) cfun->unexpanded_var_list = tree_cons (NULL_TREE, var, cfun->unexpanded_var_list); else cfun->unexpanded_var_list = tree_cons (NULL_TREE, remap_decl (var, id), cfun->unexpanded_var_list); } asm isn't written, but the variable IMHO still needs remapping, at least to get the LABEL_DECL in the initializer remapped. In C there shouldn't be a problem with ODR, in C++ not sure what happens if initializer of some inline fn local var has &&label in its initializer - issue an error? -- Summary: tree-inline.c bug with local static vars Product: gcc Version: 4.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jakub at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29484