This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 119a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2025-12-20
[Adopted at the February/March, 2017 meeting.]
An example in6.7 [basic.link] paragraph 6 creates two file-scope variableswith the same name,one with internal linkage and one with external.
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 } }Is this really what we want?C99 has 6.2.2.7/7,which gives undefined behavior for having an identifier appear withinternal and external linkage in the same translation unit. C++doesn't seem to have an equivalent.
Notes from October 2003 meeting:
We agree that this is an error. We propose to leave the examplebut change the comment to indicate that line //3 has undefinedbehavior, and elsewhere add a normative rule giving such acase undefined behavior.
Proposed resolution (October, 2005) [SUPERSEDED]:
Change 6.7 [basic.link] paragraph 6 as indicated:
...Otherwise, if no matching entity is found, the block scope entityreceives external linkage.If, within a translation unit, the sameentity is declared with both internal and external linkage, thebehavior is undefined.
[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 namedi in this program. Theobject with internal linkage introduced by the declaration in globalscope (line//1 ), the object with automatic storage durationand no linkage introduced by the declaration on line//2, andthe object with static storage duration and external linkageintroduced by the declaration on line//3.Without thedeclaration at line//2, the declaration at line//3would link with the declaration at line//1. But because thedeclaration with internal linkage is hidden,//3 is givenexternal linkage, resulting in a linkage conflict. —endexample]
Notes from the April 2006 meeting:
According to 6.7 [basic.link] paragraph 9, the twovariables with linkage in the proposed example are not “thesame entity” because they do not have the same linkage. Some otherformulation will be needed to describe the relationship between thosetwo variables.
Notes from the October 2006 meeting:
The CWG decided that it would be better to make a program with thiskind of linkage mismatch ill-formed instead of having undefinedbehavior.
Proposed resolution (November, 2016):
Change 6.7 [basic.link] paragraph 6 as follows:
...Otherwise, if no matching entity is found, the block scope entityreceives external linkage.If, within a translation unit, thesame entity is declared with both internal and external linkage, theprogram is ill-formed. [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, ill-formed } }
There are three objects namedi in this program. Theobject with internal linkage introduced by the declaration in global scope(line #1 ), the object with automatic storage duration and no linkageintroduced by the declaration on line #2, and the object with staticstorage duration and external linkage introduced by the declaration on line#3.Without the declaration at line #2, the declaration at line#3 would link with the declaration at line #1. Because the declaration withinternal linkage is hidden, however, #3 is given external linkage, makingthe program ill-formed. —end example]