The following snippet ICEs. See https://godbolt.org/z/-fZVX4. ```C++ template <class T> struct type { T value; }; template <class T> type(T) -> type<T>; void f() { []<template <class> class... Ts>() { (..., []<template <class> class T>() { T{0}; }.template operator()<Ts>()); } .template operator()<type>(); } ```
Perhaps it's related to the following snippet that errors. I don't see why it shouldn't work. Should I open a separate bug report on this? ```C++ template <template <class> class... Ts> void g() { (..., Ts{0}); // error: operand of fold expression has no unexpanded parameter packs } ```
Confirmed. Fails on trunk, too.
Another example: https://godbolt.org/z/Wq1vjP. Perhaps, this too requires another bug report. ```C++ template <template <class> class T, class... Us> concept ctadable = requires(Us... us) { T{us...}; }; template <class T> struct X { T x; }; static_assert(ctadable<X, int>); ```
Looks like the testcases in comment #1 and comment #3 are PR98611 and are fixed for GCC 11 with r11-6614. We still ICE on your original testcase though. Reduced: template <class> void f() { []<template <class> class U>() { U{0}; }; } template void f<int>();
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>: https://gcc.gnu.org/g:cafcfcb5840b62d9fc80c12192189351e995a4f2 commit r11-6816-gcafcfcb5840b62d9fc80c12192189351e995a4f2 Author: Patrick Palka <ppalka@redhat.com> Date: Wed Jan 20 09:44:33 2021 -0500 c++: Fix tsubsting CLASS_PLACEHOLDER_TEMPLATE [PR95434] Here, during partial instantiation of the generic lambda, we do tsubst_copy on the CLASS_PLACEHOLDER_TEMPLATE for U{0} which yields a (level-lowered) TEMPLATE_TEMPLATE_PARM rather than the corresponding TEMPLATE_DECL. This later confuses do_class_deduction which expects that a CLASS_PLACEHOLDER_TEMPLATE is always a TEMPLATE_DECL. gcc/cp/ChangeLog: PR c++/95434 * pt.c (tsubst) <case TEMPLATE_TYPE_PARM>: If tsubsting CLASS_PLACEHOLDER_TEMPLATE yields a TEMPLATE_TEMPLATE_PARM, adjust to its TEMPLATE_TEMPLATE_PARM_TEMPLATE_DECL. gcc/testsuite/ChangeLog: PR c++/95434 * g++.dg/cpp2a/lambda-generic9.C: New test.
Thank you.
The releases/gcc-10 branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>: https://gcc.gnu.org/g:2400f81c2c2489f4b6fbb245ef946a39be40defd commit r10-9734-g2400f81c2c2489f4b6fbb245ef946a39be40defd Author: Patrick Palka <ppalka@redhat.com> Date: Tue Apr 20 12:06:27 2021 -0400 c++: Fix tsubsting CLASS_PLACEHOLDER_TEMPLATE [PR95434] Here, during partial instantiation of the generic lambda, we do tsubst_copy on the CLASS_PLACEHOLDER_TEMPLATE for U{0} which yields a (level-lowered) TEMPLATE_TEMPLATE_PARM rather than the corresponding TEMPLATE_DECL. This later confuses do_class_deduction which expects that a CLASS_PLACEHOLDER_TEMPLATE is always a TEMPLATE_DECL. gcc/cp/ChangeLog: PR c++/95434 * pt.c (tsubst) <case TEMPLATE_TYPE_PARM>: If tsubsting CLASS_PLACEHOLDER_TEMPLATE yields a TEMPLATE_TEMPLATE_PARM, adjust to its TEMPLATE_TEMPLATE_PARM_TEMPLATE_DECL. gcc/testsuite/ChangeLog: PR c++/95434 * g++.dg/cpp2a/lambda-generic9.C: New test. (cherry picked from commit cafcfcb5840b62d9fc80c12192189351e995a4f2)