Created on 2013-12-04.00:00:00 last changed 122 months ago
Additional note, November, 2014:
The issue has been returned to "drafting" status to clarify the circumstances under which a preceding declaration supplies the language linkage for a declaration (for example, not when the declaration uses a typedef, which carries the language linkage, but only when the declaration uses a function declarator).
Proposed resolution (February, 2014):
Change 9.11 [dcl.link] paragraph 4 as follows:
Linkage specifications nest. When linkage specifications nest, the innermost one determines the language linkage. A linkage specification does not establish a scope. A linkage-specification shall occur only in namespace scope (6.4 [basic.scope]). In a linkage-specification, the specified language linkage applies to the function types of all function declarators, function names with external linkage, and variable names with external linkage declared within the linkage-specification, including those appearing in scopes nested inside the linkage specification and not inside a nested linkage-specification. [Example:
...
extern "C" { static void f4(); // the name of the function f4 has // internal linkage (not C language // linkage) and the function's type // has C language linkage. } extern "C" void f5() { extern void f4(); // OK: Name linkage (internal) //and function type linkage (C//language linkage)gotten from // previous declaration.; function type // linkage (C language // linkage) gotten // from linkage specification }
According to 9.1 [dcl.pre] paragraph 2,
Unless otherwise stated, utterances in Clause 9 [dcl.dcl] about components in, of, or contained by a declaration or subcomponent thereof refer only to those components of the declaration that are not nested within scopes nested within the declaration.
This contradicts the intent of 9.11 [dcl.link] paragraph 4, which says,
In a linkage-specification, the specified language linkage applies to the function types of all function declarators, function names with external linkage, and variable names with external linkage declared within the linkage-specification.
Also, one of the comments in the example in paragraph 4 is inconsistent with the intent:
extern "C" { static void f4(); // the name of the function f4 has // internal linkage (not C language // linkage) and the function's type // has C language linkage. } extern "C" void f5() { extern void f4(); // OK: Name linkage (internal) // and function type linkage (C // language linkage) gotten from // previous declaration. }
The language linkage for the block-scope declaration of f4 is presumably determined by the fact that it appears in a C-linkage function, not by the previous declaration.
History | |||
---|---|---|---|
Date | User | Action | Args |
2014-11-24 00:00:00 | admin | set | messages: + msg5204 |
2014-11-24 00:00:00 | admin | set | status: ready -> drafting |
2014-03-03 00:00:00 | admin | set | messages: + msg4827 |
2014-03-03 00:00:00 | admin | set | status: open -> ready |
2013-12-04 00:00:00 | admin | create |