Testcase (https://godbolt.org/g/mNhetZ): #include <array> #include <utility> using std::size_t; template <size_t... Indexes> auto f(std::index_sequence<Indexes...>) { std::array<int, sizeof...(Indexes)> x = {[&]() -> int { return Indexes; }()...}; return x; } auto g() { return f(std::make_index_sequence<3>()); } The pack expansion of `[&]() -> int { return Indexes; }()` is apparently never considered. ICC, clang, and MSVC accept the code.
GCC 8 accepts the code without any errors. Confirmed with 7.2 and the following output (please remember to provide compiler output with bug reports about wrong diagnostics): t.C: In lambda function: t.C:6:68: error: parameter packs not expanded with ‘...’: std::array<int, sizeof...(Indexes)> x = {[&]() -> int { return Indexes; }()...}; ^~~~~~~ t.C:6:68: note: ‘Indexes’ t.C: In function ‘auto f(std::index_sequence<Indexes ...>)’: t.C:6:80: error: expansion pattern ‘<lambda>()’ contains no argument packs td::array<int, sizeof...(Indexes)> x = {[&]() -> int { return Indexes; }()...}; ^~~ There have been many changes in lambda support in GCC 8. I'm not sure which one of them has fixed it or whether it would be feasible to backport it to 7.x. My guess is that it's unlikely.
Looks like a dup of PR 47226 which is already fixed on trunk, but I don't think the recent overhaul of lambda expression handling is suitable to be backported.
Resolving as a dupe of pr47226 based on comment #2. *** This bug has been marked as a duplicate of bug 47226 ***
(In reply to Jonathan Wakely from comment #2) > Looks like a dup of PR 47226 Ah, yes. Sorry for missing it, I recall seeing it before. I agree, a backport would be nice, but an overhaul is not a backportable bugfix. I really need to switch to GCC 8 just for the lambda fixes. :-) Thanks!