https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95069
Bug ID: 95069
Summary: Capture by reference cannot use list-initalization
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Keywords: rejects-valid
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
Target Milestone: ---
int i;
int& f(int& i) { return i; }
auto ok = [&x = f(i)] {};
auto err = [&x{f(i)}] {};
Clang, EDG and MSVC accept this in C++14 mode, but G++ doesn't:
l.cc:4:20: error: cannot capture ‘{f(i)}’ by reference
4 | auto err = [&x{f(i)}] {};
| ^