This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/29484] New: tree-inline.c bug with local static vars
- From: "jakub at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 16 Oct 2006 15:59:59 -0000
- Subject: [Bug tree-optimization/29484] New: tree-inline.c bug with local static vars
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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