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

2024-04-18


966. Nested types without linkage

Section: 6.6  [basic.link]     Status: CD2     Submitter: Jason Merrill     Date: 15 September, 2009

[Voted into WP at March, 2010 meeting.]

The recent changes to allow use of unnamed types as template arguments require some rethinking of how unnamed types are treated in general. At least, a class-scope unnamed type should have the same linkage as its containing class. For example:

    // File "hdr.h"
    struct S {
      static enum { No, Yes } locked;
    };
    template<class T> void f(T);

    // File "impl1.c"
    #include "hdr.h"
    template void f(decltype(S::locked));

    // File "impl2.c"
    #include "hdr.h"
    template void f(decltype(S::locked));

The two explicit instantiation directives should refer to the same specialization.

Proposed resolution (February, 2010):

Change 6.6 [basic.link] paragraph 8 as follows:

Names not covered by these rules have no linkage. Moreover, except as noted, a name declared in a local scope (6.4.3 [basic.scope.block]) has no linkage. A type is said to have linkage if and only if: