2015-10-23 13 views
8

मुझे लगता है कि मुझे एक और "क्लैंग बनाम जीसीसी" लैम्बडा और कॉल करने योग्य वस्तुओं के बीच असंगतता मिली।क्लैंग बनाम जीसीसी - खाली जेनेरिक लैम्ब्डा वैराडिक तर्क पैक

decltype(l)::operator()C::operator() के बराबर होना चाहिए, लेकिन अगर variadic पैक सामान्य लैम्ब्डा में खाली छोड़ा जाता है, जीसीसी संकलित करने के लिए मना कर दिया:

15 : error: no match for call to '(main()::) (int)' l(1);

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

15 : note: candidate expects 3 arguments, 2 provided

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

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

14 : note: template argument deduction/substitution failed:

15 : note: candidate expects 2 arguments, 1 provided

l(1);

Live example on 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); 
} 

जीसीसी बग ट्रैकर पर इस से संबंधित कुछ भी नहीं मिल सका (बहुत अधिक समय हालांकि खोज खर्च नहीं किया था) - जीसीसी गलत यहाँ है?

+1

एक जीसीसी बग की तरह दिखता है। – 0x499602D2

उत्तर

1

मैंने इस मुद्दे को जीसीसी बग #68071 के रूप में रिपोर्ट किया है।

संबंधित मुद्दे