<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 - static const member is not a constant expression when accessed from reference with 'dot' operator and used as a template parameter"
href="http://llvm.org/bugs/show_bug.cgi?id=16860">bug 16860</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 - static const member is not a constant expression when accessed from reference with 'dot' operator and used as a template parameter"
href="http://llvm.org/bugs/show_bug.cgi?id=16860#c1">Comment # 1</a>
on <a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED INVALID - static const member is not a constant expression when accessed from reference with 'dot' operator and used as a template parameter"
href="http://llvm.org/bugs/show_bug.cgi?id=16860">bug 16860</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>This code is ill-formed.
int arr[rt.value]; is accepted because, as a GNU/C++14 extension, we accept
variable-length arrays ("arrays of runtime bound" in C++14 parlance) by
default. We'll reject that too if you build with -pedantic-errors.
'rt.value' is not a constant expression because the evaluation of 'rt' as an
lvalue is not permitted in a constant expression: a reference can only be used
in a constant expression if it is initialized by a constant expression (see
5.19/2). 't' is not a reference constant expression because it is an object of
automatic storage duration (see 5.19/4).
I sympathize here -- the code is certainly reasonable -- but gcc is wrong to
accept it. The natural way to allow this would be to weaken the requirement on
references from "initialized by a constant expression" to "initialized by a
core constant expression", but this code example alone doesn't seem like
sufficient justification for that.</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>