This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: static declaration follows non-static one
- From: Kalle Olavi Niemitalo <kon at iki dot fi>
- To: Andrew Makhorin <mao at gnu dot org>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Tue, 28 Jun 2016 08:18:43 +0300
- Subject: Re: static declaration follows non-static one
- Authentication-results: sourceware.org; auth=none
- References: <1467086788 dot 542 dot 2 dot camel at corvax>
Andrew Makhorin <mao@gnu.org> writes:
> However, the Standard says:
>
> If the declaration of an identifier for an object or a function
> contains the storage-class specifier extern, the identifier has
> the same linkage as any visible declaration of the identifier
> with file scope.
>
> Is it a gcc bug or I misunderstand something?
That paragraph does not apply because the later static
declaration is not visible at the earlier extern declaration.
Although both declarations have file scope, their scopes do not
begin at the same point, and no declaration is visible outside
its scope.
That wording in ISO/IEC 9899:1990 subclause 6.1.2.2 was also
changed in TC1, see: http://www.lysator.liu.se/c/tc1.html
And C99+TC1 subclause 6.2.2 is a bit different again.