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

2024-12-19


2872. Linkage and unclear "can be referred to"

Section: 6.6  [basic.link]     Status: DRWP     Submitter: Brian Bi     Date: 2024-03-08

[Accepted as a DR at the June, 2024 meeting.]

It is unclear what "can be referred to" means in 6.6 [basic.link] paragraph 2. Paragraph 8 provides precise definitions for "same entity".

Possible resolution [SUPERSEDED]:

  1. Replace in 6.6 [basic.link] paragraph 2 as follows:

    A name is said to have linkage when it can denote the same object, reference, function, type, template, namespace or value as a name introduced by a declaration in another scope:
    • When a name has external linkage, the entity it denotes can be referred to by names from scopes of other translation units or from other scopes of the same translation unit.
    • When a name has module linkage, the entity it denotes can be referred to by names from other scopes of the same module unit (10.1 [module.unit]) or from scopes of other module units of that same module.
    • When a name has internal linkage, the entity it denotes can be referred to by names from other scopes in the same translation unit.
    • When a name has no linkage, the entity it denotes cannot be referred to by names from other scopes.
    A name can have external linkage, module linkage, internal linkage, or no linkage, as determined by the rules below. [ Note: The linkage of a name determines when corresponding declarations (6.4.1 [basic.scope.scope]) that introduce that name can declare the same entity. ---end note]
  2. Change in 11.6 [class.local] paragraph 3 as follows:

    If class X is a local class, a nested class Y may be declared in class X and later defined in the definition of class X or be later defined in the same scope as the definition of class X. A class nested within a local class is a local class. A member of a local class X shall be declared only in the definition of X or the nearest enclosing block scope of X.

CWG 2024-05-03

CWG opined to split off the second change (see issue 2890) and clarify the note.

Proposed resolution (approved by CWG 2024-05-17):

Replace in 6.6 [basic.link] paragraph 2 as follows:

A name is said to have linkage when it can denote the same object, reference, function, type, template, namespace or value as a name introduced by a declaration in another scope:
A name can have external linkage, module linkage, internal linkage, or no linkage, as determined by the rules below. [ Note: All declarations of an entity with a name with internal linkage appear in the same translation unit. All declarations of an entity with module linkage are attached to the same module. ---end note]