<html>
<head>
<base href="http://llvm.org/bugs/" />
</head>
<body><span class="vcard"><a class="email" href="mailto:richard-llvm@metafoo.co.uk" title="Richard Smith <richard-llvm@metafoo.co.uk>"> <span class="fn">Richard Smith</span></a>
</span> changed
<a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED INVALID - clang c++ should not allow a name with no linkage to declare an entity with linkage"
href="http://llvm.org/bugs/show_bug.cgi?id=5905">bug 5905</a>
<br>
<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>What</th>
<th>Removed</th>
<th>Added</th>
</tr>
<tr>
<td style="text-align:right;">Status</td>
<td>ASSIGNED
</td>
<td>RESOLVED
</td>
</tr>
<tr>
<td style="text-align:right;">CC</td>
<td>
</td>
<td>richard-llvm@metafoo.co.uk
</td>
</tr>
<tr>
<td style="text-align:right;">Resolution</td>
<td>---
</td>
<td>INVALID
</td>
</tr></table>
<p>
<div>
<b><a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED INVALID - clang c++ should not allow a name with no linkage to declare an entity with linkage"
href="http://llvm.org/bugs/show_bug.cgi?id=5905#c5">Comment # 5</a>
on <a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED INVALID - clang c++ should not allow a name with no linkage to declare an entity with linkage"
href="http://llvm.org/bugs/show_bug.cgi?id=5905">bug 5905</a>
from <span class="vcard"><a class="email" href="mailto:richard-llvm@metafoo.co.uk" title="Richard Smith <richard-llvm@metafoo.co.uk>"> <span class="fn">Richard Smith</span></a>
</span></b>
<pre>The original code here is actually valid. Per C++ 3.5/8, "a type without
linkage shall not be used as the type of a variable [...] with external linkage
unless [...] the entity is not odr-used or is defined in the same translation
unit". In this case, the variable satisfies *both* of these criteria.
If we write:
union {
int x;
float y;
} extern anon; // not defined in this TU
int main() {
return anon.x; // odr-used in this TU
}
... then clang issues a diagnostic:
<stdin>:4:10: warning: variable '<anonymous namespace>::anon' has internal
linkage but is not defined [-Wundefined-internal]
} extern anon;
^
<stdin>:7:10: note: used here
return anon.x;
^
This still isn't quite right: we claim that 'anon' has internal linkage, but it
actually should have external linkage, and -pedantic-errors doesn't promote
this diagnostic to an error, but it's enough to be conforming.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>