Affected subclause: [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 (
[basic.def.odr])
in this revision of C++
. For example:
namespace { extern "C" { extern int x; } }
namespace A { extern "C" int x = 42; }
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
.