The following valid code snippet (compiled with "-std=c++11") rejected in GCC 5.0.0 (20150103) but compiles with Clang normal: ======================================================= #include <iostream> template <int _i> struct Lmb { static void fff() { std::cout << _i << std::endl; } }; template <int... _is> struct Expand { Expand() { } static constexpr uint m_size = sizeof...(_is); static void (*const m_arr[m_size])(); }; template <int... _is> void (*const Expand<_is...>::m_arr[m_size])() = { [] () { std::cout << _is << std::endl; } ... //Lmb<_is>::fff... }; int main() { Expand<12,34,56> e; e.m_arr[0](); e.m_arr[1](); e.m_arr[2](); return 24; } ======================================================= GCC 5.0.0 (20150103) output: ------------------------------------------------------- prog.cc: In lambda function: prog.cc:20:46: error: parameter packs not expanded with '...': [] () { std::cout << _is << std::endl; } ... ^ prog.cc:20:46: note: '_is' prog.cc: At global scope: prog.cc:20:50: error: expansion pattern '<lambda>' contains no argument packs [] () { std::cout << _is << std::endl; } ... ^
Reduced: template <int... _is> struct Expand { static void (*const m_arr[sizeof...(_is)])(); }; template <int... _is> void (*const Expand<_is...>::m_arr[])() = { [] () { (void)_is; } ... }; int main() { Expand<12,34,56> e; e.m_arr[0](); e.m_arr[1](); e.m_arr[2](); }
probably a dup of PR 47226
Further simplification: template <int... Is> void foo() { using arr = int(*[])(); (void) arr{[]{ return Is; }...}; } int main() { foo<1,2,3>(); } * clang++ 3.3 (up to 5.0) happily compiles the code with -std=c++11. * g++ 4.7 (up to 7.0) fails to compile with -std=c++11 (or c++14/c++1z)
Fixed. *** This bug has been marked as a duplicate of bug 47226 ***