Title
More errors from internal-linkage namespaces
Status
cd6
Section
6.6 [basic.link]
Submitter
Richard Smith

Created on 2014-12-15.00:00:00 last changed 19 months ago

Messages

Date: 2020-11-15.00:00:00

[Accepted at the November, 2020 meeting as part of paper P1787R6 and moved to DR at the February, 2021 meeting.]

Issue 1603 dealt with omissions in the application of the change to give unnamed namespaces internal linkage, but its resolution overlooked a couple of items. According to 6.6 [basic.link] paragraph 6,

The name of a function declared in block scope and the name of a variable declared by a block scope extern declaration have linkage. If there is a visible declaration of an entity with linkage having the same name and type, ignoring entities declared outside the innermost enclosing namespace scope, the block scope declaration declares that same entity and receives the linkage of the previous declaration. If there is more than one such matching entity, the program is ill-formed. Otherwise, if no matching entity is found, the block scope entity receives external linkage.

The last sentence should say, “...receives the linkage of the innermost enclosing namespace.”

Also, 6.6 [basic.link] paragraph 8 says,

A type without linkage shall not be used as the type of a variable or function with external linkage unless

  • ...

  • the entity is declared within an unnamed namespace (9.8.2 [namespace.def]), or

  • ...

This bullet cannot occur, since a function or variable declared within an unnamed namespace cannot have external linkage.

History
Date User Action Args
2022-08-19 07:54:33adminsetstatus: drwp -> cd6
2021-02-24 00:00:00adminsetstatus: accepted -> drwp
2020-12-15 00:00:00adminsetstatus: drafting -> accepted
2014-12-15 00:00:00admincreate