Title
Linkage of member of unnamed namespace
Status
cd3
Section
9.2.2 [dcl.stc]
Submitter
Nikolay Ivchenkov

Created on 2012-08-24.00:00:00 last changed 130 months ago

Messages

Date: 2013-04-15.00:00:00

[Moved to DR at the April, 2013 meeting.]

Date: 2012-10-15.00:00:00

Proposed resolution (October, 2012):

Delete 9.2.2 [dcl.stc] paragraph 7:

A name declared in a namespace scope without a storage-class-specifier has external linkage unless it has internal linkage because of a previous declaration and provided it is not declared const. Objects declared const and not explicitly declared extern have internal linkage.
Date: 2012-08-24.00:00:00

There is a contradiction in the specification of the linkage of members of the unnamed namespace, for example

  namespace {
    int x;
  }

According to 6.6 [basic.link] paragraph 4,

An unnamed namespace or a namespace declared directly or indirectly within an unnamed namespace has internal linkage. All other namespaces have external linkage. A name having namespace scope that has not been given internal linkage above has the same linkage as the enclosing namespace if it is the name of

  • a variable; or

  • ...

which would give x internal linkage. However, 9.2.2 [dcl.stc] paragraph 7 says,

A name declared in a namespace scope without a storage-class-specifier has external linkage unless it has internal linkage because of a previous declaration and provided it is not declared const.

This would give x external linkage. (This appears to have been a missed edit from the resolution of issue 1113.)

History
Date User Action Args
2014-03-03 00:00:00adminsetstatus: drwp -> cd3
2013-10-14 00:00:00adminsetstatus: dr -> drwp
2013-05-03 00:00:00adminsetmessages: + msg4398
2013-05-03 00:00:00adminsetstatus: ready -> dr
2012-11-03 00:00:00adminsetmessages: + msg4059
2012-11-03 00:00:00adminsetstatus: open -> ready
2012-08-24 00:00:00admincreate