https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68177
Bug ID: 68177 Summary: Lambda capture doesn't work correctly when lambda is used in a pack expansion Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: rs2740 at gmail dot com Target Milestone: --- Repro: void swallow(...) {} template<int... Is> void foo() { int t = 0; swallow( ([&t]{return 0;}(), Is)... ); } int main() { foo<1, 2>(); return 0; } gcc HEAD 6.0.0 20151031 (experimental) reports: prog.cc: In instantiation of 'void foo() [with int ...Is = 1, 2]': prog.cc:13:13: required from here prog.cc:6:5: error: member 'foo() [with int ...Is = 1, 2]::<lambda()>::<t capture>' is uninitialized reference ([&t]{return 0;}(), Is)... ^ It appears that only the capture in the first element in the pack expansion gets initialized correctly. Clang accepts this code, as does MSVC.