circle
circle copied to clipboard
circle: "error forming list comprehension" when compiling __device__ lambda
The program
int main()
{
auto device_lambda = [] __device__ () {};
return 0;
}
Causes circle to emit the error message
$ circle --cuda-path=/usr/local/cuda -sm_50 repro.cu
error: repro.cu:3:24
error forming list comprehension
auto device_lambda = [] __device__ () {};
^
error: repro.cu:3:25
expected 1 or more items in initializer-list
auto device_lambda = [] __device__ () {};
Compiler details:
$ ~/Desktop/circle/circle --version
circle version 1.0.0-136
Circle public preview build 136
Built Sep 27 2021 23:42:52
(c) 2021 Sean Baxter
https://www.circle-lang.org/
Twitter: @seanbax

There is no attribute-specifier-seq in that position, by the standard. I do parse attributes after the ( ), (accessible through the lambda-specifiers in the grammar). The error you are seeing is due to the existence of a Python-style list comprehension in Circle. It thinks [] is for the list comprehension, since it doesn't match the lambda grammar as implemented.
If I add attribute-specifier-seq parsing immediately after the lambda-introducer like you show, does this get us anything? This is to compile with existing nvcc code? You definitely don't need/want it with new code. Do you know if nvc++ supports that syntax?
You can leave the device tag off the lambda and it will work when called from the kernel.
Do you know if nvc++ supports that syntax?
Yes, it's a so-called "extended lambda" enabled with --expt-extended-lambda