This is the mail archive of the
mailing list for the GCC project.
Re: Redeclaration of used symbols
- From: "Zack Weinberg" <zack at codesourcery dot com>
- To: Jan Hubicka <hubicka at ucw dot cz>
- Cc: gcc at gcc dot gnu dot org, schwab at suse dot de, rth at redhat dot com
- Date: Sun, 07 Sep 2003 09:57:28 -0700
- Subject: Re: Redeclaration of used symbols
- References: <20030907135208.GC14387@kam.mff.cuni.cz>
Jan Hubicka <email@example.com> writes:
> We currently accept the following testcase:
> static int t();
> when compiled with -fPIC we get an global symbol t that is called as if
> it were local symbol in non-PIC way on i386. I believe we get similar
> misscompilations on most of other targets as well as confussion of the
> unit-at-a-time code and such.
> Is this valid C?
No, it's undefined behavior - t is declared in the same scope with two
different linkages. (6.2.2p7)
> If so, what should be semantic in function-at-a-time compilation?
> If not, what is the best way to error about it? (check in
> duplicate_decls whether entity has an initializer or is used comes
> into mind)
You could simply remove the special case code in duplicate_decls that
lets this go through. I am in favor of making it a hard error even in
non-unit-at-a-time mode -- I don't think the validity of code should
depend on whether or not the translation unit is being analyzed in