Skip to content

Commit 155e163

Browse files
burblebeetkoeppe
authored andcommitted
CWG2772 Missing Annex C entry for linkage effects of linkage-specification
1 parent 9539ea7 commit 155e163

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

source/compatibility.tex

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1826,6 +1826,27 @@
18261826
revision of \Cpp{} because \tcode{double} to \tcode{int} is a narrowing
18271827
conversion.
18281828

1829+
\diffref{dcl.link}
1830+
\change
1831+
Names declared in an anonymous namespace
1832+
changed from external linkage to internal linkage;
1833+
language linkage applies to names with external linkage only.
1834+
\rationale
1835+
Alignment with user expectations.
1836+
\effect
1837+
Valid \CppIII{} code may violate the one-definition rule\iref{basic.def.odr}
1838+
in this revision of \Cpp{}.
1839+
For example:
1840+
\begin{codeblock}
1841+
namespace { extern "C" { extern int x; } } // \#1, previously external linkage and C language linkage,
1842+
// now internal linkage and \Cpp{} language linkage
1843+
namespace A { extern "C" int x = 42; } // \#2, external linkage and C language linkage
1844+
int main(void) { return x; }
1845+
\end{codeblock}
1846+
This code is valid in \CppIII{},
1847+
but \tcode{\#2} is not a definition for \tcode{\#1}
1848+
in this revision of \Cpp{}, violating the one-definition rule.
1849+
18291850
\rSec2[diff.cpp03.class]{\ref{class}: classes}
18301851

18311852
\diffref{class.default.ctor,class.dtor,class.copy.ctor,class.copy.assign}

0 commit comments

Comments
 (0)