This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 110b. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2023-01-15


1544. Linkage of member of unnamed namespace

Section: 9.2.2  [dcl.stc]     Status: CD3     Submitter: Nikolay Ivchenkov     Date: 2012-08-24

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

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

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.)

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.