<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 --- - constexpr value in a lambda"
href="https://llvm.org/bugs/show_bug.cgi?id=25627">25627</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>constexpr value in a lambda
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</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>al-iyaz@xs4all.nl
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=15348" name="attach_15348" title="as explained">attachment 15348</a> <a href="attachment.cgi?id=15348&action=edit" title="as explained">[details]</a></span>
as explained
If I am correct the following code should be valid c++14:
template<int j> void g() {}
int main()
{
constexpr int i = 0;
auto f = []{ g<i>(); };
return 0;
}
However, clang does not compile this code.
It does compile with when capturing [=], [i] or [&].
It also compiles if the i is made static.
This is related to a stackoverflow-question:
<a href="http://stackoverflow.com/questions/33873788/how-can-i-use-a-constexpr-value-in-a-lambda">http://stackoverflow.com/questions/33873788/how-can-i-use-a-constexpr-value-in-a-lambda</a>
clang version:
Debian clang version 3.8.0-svn247818-1~exp1 (trunk) (based on LLVM 3.8.0)
compile command:
clang++-3.8 -std=c++14 capture_constexpr.cpp
compiler error:
capture_constexpr.cpp:11:7: error: variable 'i' cannot be implicitly captured
in a lambda with no capture-default specified
g<i>();
^
capture_constexpr.cpp:7:17: note: 'i' declared here
constexpr int i = 0;
^
capture_constexpr.cpp:10:12: note: lambda expression begins here
auto f = []{ // compiles with gcc 4.9.1, not with clang 3.8
^
1 error generated.</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>