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