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

            Bug ID: 80795
           Summary: Cannot take the address of call operator of a variadic
                    lambda when parameter pack length differs from 1
           Product: gcc
           Version: 7.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gufideg at gmail dot com
  Target Milestone: ---

Hi there, I stumble across this error:

    int main() {
        auto test = [](auto, auto, auto...) {};
        auto ash = &decltype(test)::operator()<int, int>;
    }

In this case, I expect the pointer to the function to be the one this
expression would call:

    [](auto, auto, auto...){}(1, 1);

Leaving the parameter pack empty.
But it fails with this error:

> main.cpp: In function 'int main()':
> main.cpp:3:30: error: unable to deduce 'auto' from '& operator()<int, int>'
>   auto ash = &decltype(test)::operator()<int, int>;
>                               ^~~~~~~~~~~~~~~~~~~~
> main.cpp:3:30: note:   couldn't deduce template parameter 'auto'

The same happen when Sending two parameter in the pack:

    int main() {
        auto test = [](auto, auto, auto...) {};
        auto ash = &decltype(test)::operator()<int, int, int, int>;
    }

Note that taking the pointer when exactly one parameter fits in the pack, it
compiles fine:

    int main() {
        auto test = [](auto, auto, auto...) {};
        auto ash = &decltype(test)::operator()<int, int, int>;
    }

All of the example above compiles fine under clang.

Reply via email to