<html>
<head>
<base href="https://llvm.org/bugs/" />
</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 --- - Generic lambda init-captures can't be captured again" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D23856&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=Ppq08TRXLgCNql0fTr7vvPOBNyAA7nF_ZJ-4ErxY-L0&s=MMaGhsVp0U5P3KAFM-rnNTOd2Aw6lbTa6bIqIPA3Bho&e=">23856</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Generic lambda init-captures can't be captured again
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.6
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</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++14
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>jvp4846@g.rit.edu
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=14476" name="attach_14476" title="Test case">attachment 14476</a> <a href="attachment.cgi?id=14476&action=edit" title="Test case">[details]</a></span>
Test case
Sorry for the confusing bug title; I couldn't come up with a better description
that wasn't incredibly verbose. Anyway...
If you use an init-capture with a generic lambda, and then in turn capture that
capture in another lambda, the compiler fails, thinking that the variable used
in the init-capture's *initializer* is being *captured*. See the test file,
which produces these errors on clang 3.4, 3.5, and 3.6 (full versions below):
--------------------
$ clang++-3.4 -std=c++1y test.cpp
test.cpp:10:17: error: variable 'i' cannot be implicitly captured in a lambda
with no capture-default specified
auto f = [cap=i*2](auto) {
^
test.cpp:5:3: note: in instantiation of function template specialization
'main()::<anonymous class>::operator()<int>' requested here
f(1); // (1)
^
test.cpp:13:3: note: in instantiation of function template specialization
'metafunc<<lambda at test.cpp:10:12> >' requested here
metafunc(f);
^
test.cpp:9:7: note: 'i' declared here
int i = 1;
^
test.cpp:10:12: note: lambda expression begins here
auto f = [cap=i*2](auto) {
^
1 error generated.
--------------------
The full versions of clang are:
Ubuntu clang version 3.4.2- (branches/release_34) (based on LLVM 3.4.2)
Target: x86_64-pc-linux-gnu
Thread model: posix
Debian clang version 3.5.2-svn232162-1~exp1 (branches/release_35) (based on
LLVM 3.5.2)
Target: x86_64-pc-linux-gnu
Thread model: posix
Ubuntu clang version 3.6.0-2ubuntu1~trusty1 (tags/RELEASE_360/final) (based
on LLVM 3.6.0)
Target: x86_64-pc-linux-gnu
Thread model: posix</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>