Title
Nested types without linkage
Status
cd2
Section
6.6 [basic.link]
Submitter
Jason Merrill

Created on 2009-09-15.00:00:00 last changed 178 months ago

Messages

Date: 2010-03-15.00:00:00

[Voted into WP at March, 2010 meeting.]

Date: 2010-02-15.00:00:00

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:

  • it is a class or enumeration type that is named (or has a name for linkage purposes (9.2.4 [dcl.typedef])) and the name has linkage; or

  • it is an unnamed class or enumeration member of a class with linkage; or

  • ...

Date: 2009-09-15.00:00:00

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.

History
Date User Action Args
2010-03-29 00:00:00adminsetmessages: + msg2662
2010-03-29 00:00:00adminsetstatus: tentatively ready -> cd2
2010-02-16 00:00:00adminsetmessages: + msg2493
2010-02-16 00:00:00adminsetstatus: drafting -> tentatively ready
2009-11-08 00:00:00adminsetstatus: open -> drafting
2009-09-15 00:00:00admincreate