http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57649
Eric Botcazou <ebotcazou at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2013-06-19 CC| |ebotcazou at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #1 from Eric Botcazou <ebotcazou at gcc dot gnu.org> --- We have this patchlet in our 4.7 tree: --- a/gcc/tree-dfa.c +++ b/gcc/tree-dfa.c @@ -590,10 +590,13 @@ add_referenced_var (tree var) /* Scan DECL_INITIAL for pointer variables as they may contain address arithmetic referencing the address of other variables. As we are only interested in directly referenced - globals or referenced locals restrict this to initializers - than can refer to local variables. */ + globals or referenced locals, restrict this to initializers + than can refer to local variables. But we need to do it for + initializers of global variables declared in parent functions + lest these variables aren't referenced anywhere else. */ if (DECL_INITIAL (var) - && DECL_CONTEXT (var) == current_function_decl) + && (DECL_CONTEXT (var) == current_function_decl + || (!DECL_FILE_SCOPE_P (var) && is_global_var (var)))) walk_tree (&DECL_INITIAL (var), find_vars_r, NULL, 0); return true; * tree-dfa.c (add_referenced_var): Find variables referenced in the initializers of global variables declared in parent functions.