<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 - accessing an element of `constexpr static array` inaccurately treated as ODR-usage"
href="http://llvm.org/bugs/show_bug.cgi?id=19643">bug 19643</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>NEW
</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 - accessing an element of `constexpr static array` inaccurately treated as ODR-usage"
href="http://llvm.org/bugs/show_bug.cgi?id=19643#c1">Comment # 1</a>
on <a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED INVALID - accessing an element of `constexpr static array` inaccurately treated as ODR-usage"
href="http://llvm.org/bugs/show_bug.cgi?id=19643">bug 19643</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>Sorry, that's not correct.
We have the expression A::a[0]. Let's walk through 3.2/3:
"A variable x [A::a] whose name appears as a potentially-evaluated expression
ex [the id-expression A::a, check] is odr-used unless
applying the lvalue-to-rvalue conversion to x yields a constant expression
[it does]
that does not invoke any non-trivial functions [it does not] and,
if x is an object [it is],
ex is an element of the set of potential results of an expression e, where
either the lvalue-to-rvalue conversion is applied to e, or e is a
discarded-value expression."
So: what possible values of 'e' are there? The set of potential results of an
expression is a set of subexpressions of the expression, so we only need to
consider expressions of which 'ex' is a subexpression. Those are:
A::a
A::a[0]
Of these, the lvalue-to-rvalue conversion is *not* applied immediately to A::a,
so we only consider A::a[0]. Per 3.2/2, the set of potential results of A::a[0]
is empty, so A::a is odr-used by this expression.
Now, you could argue that we first rewrite A::a[0] to *(A::a + 0). But that
changes nothing: the possible values of e are then
A::a
A::a + 0
(A::a + 0)
*(A::a + 0)
Of these, only the fourth has an lvalue-to-rvalue conversion applied to it, and
again, 3.2/2 says that the set of potential results of *(A::a + 0) is empty.</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>