Created on2013-01-09.00:00:00 last changed109 months ago
[Moved to DR at the November, 2014 meeting.]
Proposed resolution (April, 2013):
Change 6.7 [basic.link] paragraph 5 as follows:
In addition, a member function, static data member, a named class orenumeration of class scope, or an unnamed class or enumeration defined in aclass-scope typedef declaration such that the class or enumeration has thetypedef name for linkage purposes (9.2.4 [dcl.typedef]),hasexternal linkage if the name of the class has externallinkagethe same linkage, if any, as the name of the class ofwhich it is a member.
Change the footnote in 6.7 [basic.link] paragraph 8 asfollows:
33) A class templatealways has external linkage, and the requirementsof 13.4.2 [temp.arg.type] and 13.4.3 [temp.arg.nontype] ensure thatthe template arguments will also have appropriate linkagehasthe linkage of the innermost enclosing class or namespace in which it isdeclared.
Change 9.9.2.2 [namespace.unnamed] paragraph 1 as follows:
Anunnamed-namespace-definition behaves as if it were replacedby
inlineopt namespaceunique { /* empty body */ } using namespaceunique ; namespaceunique {namespace-body }whereinline appears if and only if it appears intheunnamed-namespace-definition
,and alloccurrences ofunique in a translation unit are replaced by the sameidentifier, and this identifier differs from all otheridentifiers in theentire program. [Footnote: Although entities inan unnamed namespace might have external linkage, they are effectivelyqualified by a name unique to their translation unit and therefore cannever be seen from any other translation unit. —endfootnote]translation unit. [Example:...
Change the note in 11.4.2 [class.mfct] paragraph 3 as follows:
[Note: Member functions of a class in namespace scopehaveexternal linkagethe linkage of that class.Member functions of a local class (11.6 [class.local]) have no linkage. See6.7 [basic.link]. —end note]
Change 11.4.9.3 [class.static.data] paragraph 5 as follows:
Static data members of a class in namespace scopehaveexternal linkagethe linkage of that class(6.7 [basic.link]).
Change 11.8.4 [class.friend] paragraph 4 as follows:
A function first declared in a friend declaration hasexternallinkagethe linkage of the namespace of which it is amember (6.7 [basic.link]). Otherwise, the function retainsits previous linkage (9.2.2 [dcl.stc]).
Change Clause 13 [temp] paragraph 4 as follows:
A template name has linkage (6.7 [basic.link]).A non-memberfunction template can have internal linkage; any other template name shallhave external linkage.Specializations (explicit or implicit) of atemplate that has internal linkage are distinct from all specializations inother translation units...
In C++03, all namespace-scope names had external linkage unlessexplicitly declared otherwise (viastatic,const,or as a member of an anonymous union). C++11 now specifies that membersof an unnamed namespace have internal linkage (seeissue 1113). This change invalidated anumber of assumptions scattered throughout the Standard that need tobe adjusted:
6.7 [basic.link] paragraph 5 says,
a member function, static data member, a named class or enumeration ofclass scope, or an unnamed class or enumeration defined in aclass-scope typedef declaration such that the class or enumeration hasthe typedef name for linkage purposes (9.2.4 [dcl.typedef]),has external linkage if the name of the class has external linkage.
There is no specification for the linkage of such members of a classwith internal linkage. Formally, at least, that leads to the statementin paragraph 8 that such members have no linkage. This omission alsocontradicts the note in 11.4.2 [class.mfct] paragraph 3:
[Note: Member functions of a class in namespace scope haveexternal linkage. Member functions of a local class (11.6 [class.local]) have no linkage. See 6.7 [basic.link].—end note]
as well as the statement in 11.4.9.3 [class.static.data] paragraph5,
Static data members of a class in namespace scope have externallinkage (6.7 [basic.link]).
The footnote in 6.7 [basic.link] paragraph 8 says,
A class template always has external linkage, and the requirements of13.4.2 [temp.arg.type] and 13.4.3 [temp.arg.nontype] ensurethat the template arguments will also have appropriate linkage.
This is incorrect, since templates in unnamed namespaces now haveinternal linkage and template arguments are no longer required to haveexternal linkage.
The statement in 9.2.2 [dcl.stc] paragraph 7 is nowfalse:
A name declared in a namespace scope without astorage-class-specifier has external linkage unless it hasinternal linkage because of a previous declaration and provided it isnot declaredconst.
The entire treatment ofunique in 9.9.2.2 [namespace.unnamed]is no longer necessary, and the footnote is incorrect:
Although entities in an unnamed namespace might have external linkage,they are effectively qualified by a name unique to their translationunit and therefore can never be seen from any other translation unit.
Names in unnamed namespaces never have external linkage.
According to 11.8.4 [class.friend] paragraph 4,
A function first declared in a friend declaration has external linkage(6.7 [basic.link]).
This presumably is incorrect for a class that is a member of anunnamed namespace.
According to Clause 13 [temp] paragraph 4,
A non-member function template can have internal linkage; any othertemplate name shall have external linkage.
Taken literally, this would mean that a template could not be amember of an unnamed namespace.
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2017-02-06 00:00:00 | admin | set | status: drwp -> cd4 |
| 2015-05-25 00:00:00 | admin | set | status: dr -> drwp |
| 2015-04-13 00:00:00 | admin | set | messages: +msg5329 |
| 2014-11-24 00:00:00 | admin | set | status: ready -> dr |
| 2014-07-07 00:00:00 | admin | set | status: review -> ready |
| 2013-05-03 00:00:00 | admin | set | messages: +msg4317 |
| 2013-05-03 00:00:00 | admin | set | status: open -> review |
| 2013-01-09 00:00:00 | admin | create | |