https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90789
zhonghao at pku dot org.cn changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|gcc |gcc complains cannot
| |capture 'f()()' by
| |reference on valid code
--- Comment #1 from zhonghao at pku dot org.cn ---
My gcc is 10.0.0, and the code is:
#include <iostream>
struct S { ~S() { std::cout << "dtor\n"; } };
const S f() { return {}; }
int main() {
[&x(f())]{ std::cout << "in lambda\n"; }();
std::cout << "end of main\n";
}
The error message is:
<source>: In function 'int main()':
<source>:5:9: error: cannot capture 'f()()' by reference
5 | [&x(f())]{ std::cout << "in lambda\n"; }();
| ^
Compiler returned: 1
I tried clang, icc, and msvc. They all accept the code.