Clang vs gcc - empty generic lambda variable argument package

I think I found another clang vs gcc contradiction between lambdas and called objects.

decltype(l)::operator() should be equivalent to C::operator() , but if the variational package is left empty in the common lambda, gcc refuses to compile:

15: error: there is no match for calling on '(main (): :) (int)' l (1);

15: note: candidate: decltype (((main (): :) 0u) .main (): :( x,)) (*) (auto: 1 &, auto: 2 & & ...)

15: note: the candidate expects 3 arguments, 2 provided

14: note: candidate: template main () ::

auto l = [] (auto & x, auto & ...) {return x; };

14: note: pattern / replace argument output fails:

15: note: the candidate expects 2 arguments, 1 subject

l (1);

Live example at godbolt.org .

 struct C { template<typename T, typename... TRest> auto operator()(T&& x, TRest&&...){ return x; } }; int main() { // Compiles both with clang and gcc. auto c = C{}; c(1); // Compiles with clang 3.7. // Does not compile with gcc 5.2. auto l = [](auto&& x, auto&&...) { return x; }; l(1); } 

Could not find anything related to this in the gcc tracker (did not spend too much time searching) - is gcc not indicated here?

+8
c ++ gcc lambda clang c ++ 14
source share
1 answer

I reported a gcc # 68071 error .

+1
source share

All Articles