[Bug c++/64488] New: [4.9/5.0][c++11] Expand initializer list with lambdas in variadic template. Reject valid code.

reagentoo at gmail dot com gcc-bugzilla@gcc.gnu.org
Sun Jan 4 16:00:00 GMT 2015


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64488

            Bug ID: 64488
           Summary: [4.9/5.0][c++11] Expand initializer list with lambdas
                    in variadic template. Reject valid code.
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: reagentoo at gmail dot com

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; } ...
                                                 ^



More information about the Gcc-bugs mailing list