Title
Missing Annex C entry for linkage effects of linkage-specification
Status
drwp
Section
C.6.4 [diff.cpp03.dcl.dcl]
Submitter
Hubert Tong

Created on 2023-07-15.00:00:00 last changed 3 months ago

Messages

Date: 2023-09-15.21:51:11

Proposed resolution (approved by CWG 2023-09-15):

Add a new paragraph in C.6.4 [diff.cpp03.dcl.dcl] as follows:

Affected subclause: 9.11 [dcl.link]
Change: Names declared in an anonymous namespace changed from external linkage to internal linkage; language linkage applies to names with external linkage only.
Rationale: Alignment with user expectations.
Effect on original feature: Valid C++ 2003 code may violate the one-definition rule (6.3 [basic.def.odr]) in this revision of C++. For example:
  namespace { extern "C" { extern int x; } }  // #1, previously external linkage and C language linkage, now internal linkage and C++ language linkage
  namespace A { extern "C" int x = 42; }      // #2, external linkage and C language linkage
  int main(void) { return x; }
This code is valid in C++ 2003, but #2 is not a definition for #1 in this revision of C++, violating the one-definition rule.
Date: 2023-11-15.00:00:00

[Accepted as a DR at the November, 2023 meeting.]

With C++11, anonymous namespaces changed from external linkage (with a unique namespace name) to internal linkage. That implies that extern "C", which affects names with external linkage only, no longer has an effect inside anonymous namespaces.

However, a corresponding Annex C entry is missing.

History
Date User Action Args
2024-04-05 21:43:46adminsetstatus: dr -> drwp
2023-12-19 10:15:28adminsetstatus: ready -> dr
2023-09-15 21:51:11adminsetmessages: + msg7430
2023-09-15 21:51:11adminsetstatus: open -> ready
2023-07-15 00:00:00admincreate