[basic.link]/6
The name of a function declared in block scope and the name of a variable declared by a block scope
extern
declaration have linkage. If there is a visible declaration of an entity with linkage having the same name and type, ignoring entities declared outside the innermost enclosing namespace scope, the block scope declaration declares that same entity and receives the linkage of the previous declaration. If there is more than one such matching entity, the program is ill-formed. Otherwise, if no matching entity is found, the block scope entity receives external linkage.[ Example:static void f(); static int i = 0; // #1 void g() { extern void f(); // internal linkage int i; // #2 i has no linkage { extern void f(); // internal linkage extern int i; // #3 external linkage } }
There are three objects named
i
in this program. The object with internal linkage introduced by the declaration in global scope (line #1), the object with automatic storage duration and no linkage introduced by the declaration on line #2, and the object with static storage duration and external linkage introduced by the declaration on line #3. —end example ]
I have two comments about this paragraph:
- The
static int i = 0;
declaration in the global scope is not visible inside the block containing the declarationextern int i;
(#3). Therefore we can only say that this latter declaration has external linkage, i.e., we can't associate it with declaration #1. - Otherwise, if the declaration
static int i;
is considered visible by the declaration #3, than according to the text in the paragraph, the block scope declaration declares the same entity and receives the linkage of the previous declaration, that is, internal linkage, and not external linkage, as stated in the Example.
What am I missing here?