static declaration follows non-static one

Kalle Olavi Niemitalo kon@iki.fi
Tue Jun 28 05:19:00 GMT 2016


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.



More information about the Gcc-help mailing list