This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: C identifier lookup speedups, 2/2
Zack Weinberg wrote:-
> > I do not know if any of the follow-up patches fixes it.
>
> This program is ill-formed - the static decl 'v' at file scope refers
> to the same object as the extern decl 'v' at block scope, which
> induces undefined behavior. Having said that, I do not know why it
> compiles and executes successfully on Linux but not on AIX.
>
> My inclination is to "fix" this by causing the compiler to reject the
> program, and move the test case to c-torture/noncompile. However,
> this situation was specifically allowed in the old code:
>
> #if 0
> /* This case is probably sometimes the right thing to do. */
> /* If we have a local external declaration,
> then any file-scope declaration should not
> have been static. */
> if (oldlocal == 0 && oldglobal != 0
> && !TREE_PUBLIC (oldglobal)
> && DECL_EXTERNAL (x) && TREE_PUBLIC (x))
> warning ("`%s' locally external but globally static",
> IDENTIFIER_POINTER (name));
> #endif
>
> so I would like to get reactions from other people about what GCC
> *should* do with this program before changing anything.
I agree with your inclination.
Neil.