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


2938. Inheriting linkage from a previous declaration

Section: 6.6  [basic.link]     Status: open     Submitter: Vlad Serebrennikov     Date: 2024-09-12

(From submission #609.)

Consider the following example from 6.6 [basic.link] paragraph 6:

  static void f();   // #1
  void q() {
    extern void f(); // #2, internal linkage
  }

#1 has internal linkage per 6.6 [basic.link] bullet 3.1. However, it is unclear why #2 would also get internal linkage. At issue is the phrasing in 6.6 [basic.link] paragraph 4:

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

How does the name matching for "has been given" work here, considering that functions may be overloaded, i.e. different entities may have the same name? The notion of names (as opposed to entities) having linkage is questionable to start with.

CWG 2024-11-08

While the wording is in dire need of improvement here, the intent is that "has been given" uses the "same entity" rules specified in 6.6 [basic.link] paragraph 8. Since both declarations of f correspond, have the same target scope, and are in the same translation unit, they refer to the same entity. A rewrite of 6.6 [basic.link] should improve the wording and amend the comment in the example.