[Bug c++/64095] [C++14] Ellipsis at end of generic lambda parameter-declaration-clause should be parsed as a parameter pack

malekpatryk+gcc at gmail dot com gcc-bugzilla@gcc.gnu.org
Tue Jun 21 09:00:00 GMT 2016


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

Patryk <malekpatryk+gcc at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |malekpatryk+gcc at gmail dot com

--- Comment #1 from Patryk <malekpatryk+gcc at gmail dot com> ---
Related issue https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68071.

I can confirm this is also a problem in 6.1.0 and 5.2.1. The workaround for me
for this issue is to name the parameter pack that ends up being empty:

#include <iostream>

int main()
{
  auto f = [](auto&& arg1, auto&& arg2, auto&& ...x)// this works
  //auto f = [](auto&& arg1, auto&& arg2, auto&& ...x)// this gives the below
error
  {
    std::cout << arg1 << arg2;
  };

  f("a", "b");
}

error on commented line on 5.2.1

main.cpp: In function ‘int main()’:
main.cpp:10:13: error: no match for call to ‘(main()::<lambda(auto:1&&,
auto:2&&, auto:3&&, ...)>) (const char [2], const char [2])’
   f("a", "b");
             ^
main.cpp:5:51: note: candidate: template<class auto:1, class auto:2, class
auto:3> main()::<lambda(auto:1&&, auto:2&&, auto:3&&, ...)>::operator decltype
(((main()::<lambda(auto:1&&, auto:2&&, auto:3&&, ...)>)0u).operator()(arg1,
arg2, <anonymous>)) (*)(auto:1&&, auto:2&&, auto:3&&, ...)() const <deleted>
   auto f = [](auto&& arg1, auto&& arg2, auto&& ...)
                                                   ^
main.cpp:5:51: note:   template argument deduction/substitution failed:
main.cpp:10:13: note:   candidate expects 1 argument, 2 provided
   f("a", "b");
             ^
main.cpp:5:51: note: candidate: template<class auto:1, class auto:2, class
auto:3> main()::<lambda(auto:1&&, auto:2&&, auto:3&&, ...)>
   auto f = [](auto&& arg1, auto&& arg2, auto&& ...)
                                                   ^
main.cpp:5:51: note:   template argument deduction/substitution failed:
main.cpp:10:13: note:   candidate expects 3 arguments, 2 provided
   f("a", "b");
             ^


More information about the Gcc-bugs mailing list