Title
Inheriting linkage from a previous declaration
Status
open
Section
6.6 [basic.link]
Submitter
Vlad Serebrennikov

Created on 2024-09-12.00:00:00 last changed 1 month ago

Messages

Date: 2024-11-09.00:21:39

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.

Date: 2024-09-12.00:00:00

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

History
Date User Action Args
2024-11-09 00:21:39adminsetmessages: + msg7889
2024-09-12 00:00:00admincreate