<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - decltype((x)) inside lambda is considered odr-use if x is captured"
href="https://bugs.llvm.org/show_bug.cgi?id=35423">35423</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>decltype((x)) inside lambda is considered odr-use if x is captured
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>deaeod@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre><a href="https://godbolt.org/g/NmA3ZP">https://godbolt.org/g/NmA3ZP</a>
#include <type_traits>
int main() {
int x = 1;
int&& y = static_cast<int&&>(x);
auto A = []{ static_assert(std::is_same_v<decltype((x)), int&>); };
auto B = [=]{ static_assert(std::is_same_v<decltype((x)), int&>); };
auto C = []{ static_assert(std::is_same_v<decltype((y)), int&>); };
auto D = [=]{ static_assert(std::is_same_v<decltype((y)), int&>); };
}
I expected this to compile cleanly, but static asserts B and D fail under
clang.
Here is how i would argue for my expectation:
<a href="http://eel.is/c++draft/expr.prim.lambda#capture-11.sentence-3">http://eel.is/c++draft/expr.prim.lambda#capture-11.sentence-3</a>
-- "An id-expression that is not an odr-use refers to the original entity,
never to a member of the closure type."
<a href="http://eel.is/c++draft/basic.def.odr#def:potentially_evaluated">http://eel.is/c++draft/basic.def.odr#def:potentially_evaluated</a>
-- "An expression is potentially evaluated unless it is an unevaluated
operand or a subexpression thereof."
<a href="http://eel.is/c++draft/basic.def.odr#def:odr-used">http://eel.is/c++draft/basic.def.odr#def:odr-used</a>
-- "A variable x whose name appears as a potentially-evaluated expression
ex is odr-used by ex unless [...]"
<a href="http://eel.is/c++draft/dcl.type.simple#4.sentence-3">http://eel.is/c++draft/dcl.type.simple#4.sentence-3</a>
-- "The operand of the decltype specifier is an unevaluated operand."</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>