Title
Does an alias-declaration introduce a name for linkage purposes?
Status
open
Section
9.2.4 [dcl.typedef]
Submitter
Jonathan Wakely

Created on 2024-12-19.00:00:00 last changed 2 days ago

Messages

Date: 2024-12-19.00:00:00

Consider:

   using A = struct { int i; };

Does the unnamed class have A as its name for linkage purposes? There is implementation divergence.

Possible resolution:

  1. Change in 6.6 [basic.link] paragraph 4 as follows:

    ... The name of an entity that belongs to a namespace scope, that has not been given internal linkage above, and that is the name of
    • a variable; or
    • a function; or
    • a named class (11.1 [class.pre]), or an unnamed class defined in a typedef declaration or alias-declaration in which the class has the typedef name for linkage purposes (9.2.4 [dcl.typedef]); or
    • a named enumeration (9.7.1 [dcl.enum]), or an unnamed enumeration defined in a typedef declaration or alias-declaration in which the enumeration has the typedef name for linkage purposes (9.2.4 [dcl.typedef]); or
    • an unnamed enumeration that has an enumerator as a name for linkage purposes (9.7.1 [dcl.enum]); or
    • a template
    has its linkage determined as follows: ...
  2. Change in 6.6 [basic.link] paragraph 5 as follows:

    In addition, a member function, a static data member, a named class or enumeration that inhabits a class scope, or an unnamed class or enumeration defined in a typedef declaration or alias-declaration that inhabits a class scope such that the class or enumeration has the typedef name for linkage purposes (9.2.4 [dcl.typedef]), has the same linkage, if any, as the name of the class of which it is a member.
  3. Change in 6.8.1 [basic.types.general] paragraph 6 as follows:

    ... [Note 3: The type of a pointer or reference to array of unknown bound permanently points to or refers to an incomplete type. An array of unknown bound named by a typedef declaration or alias-declaration permanently refers to an incomplete type. In either case, the array type cannot be completed. —end note] ...
  4. Change in 9.2.4 [dcl.typedef] paragraph 4 as follows:

    An unnamed class or enumeration C defined in a typedef declaration or alias-declaration has the first typedef-name declared by the declaration to be of type C as its typedef name for linkage purposes (6.6 [basic.link]). [Note 2: A typedef declaration or alias-declaration involving a lambda-expression does not itself define the associated closure type, and so the closure type is not given a typedef name for linkage purposes. —end note] [Example 4:
      typedef struct { } *ps, S;    // S is the typedef name for linkage purposes
      typedef decltype([]{}) C;     // the closure type has no typedef name for linkage purposes
      using U = class { };          // U is the typedef name for linkage purposes
    
    end example]
History
Date User Action Args
2024-12-19 00:00:00admincreate