[llvm-bugs] [Bug 25627] New: constexpr value in a lambda
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Nov 24 11:46:05 PST 2015
https://llvm.org/bugs/show_bug.cgi?id=25627
Bug ID: 25627
Summary: constexpr value in a lambda
Product: clang
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++14
Assignee: unassignedclangbugs at nondot.org
Reporter: al-iyaz at xs4all.nl
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
Created attachment 15348
--> https://llvm.org/bugs/attachment.cgi?id=15348&action=edit
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:
http://stackoverflow.com/questions/33873788/how-can-i-use-a-constexpr-value-in-a-lambda
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.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20151124/f8640759/attachment.html>
More information about the llvm-bugs
mailing list