https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109017
Bug ID: 109017 Summary: ICE on unexpanded pack from C++20 explicit-template-parameter lambda syntax Product: gcc Version: unknown Status: UNCONFIRMED Keywords: ice-on-invalid-code Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: arthur.j.odwyer at gmail dot com Target Milestone: --- // https://godbolt.org/z/bdT84P318 template<class...> struct A { static void g() { int dummy[] = { []<class... Ts>(Ts... ts){ int i = Ts(); } ... }; } }; int main() { A<int>::g(); } <source>: In instantiation of 'static void A< <template-parameter-1-1> >::g() [with <template-parameter-1-1> = {int}]': <source>:12:14: required from here <source>:4:13: internal compiler error: in tsubst_pack_expansion, at cp/pt.cc:13388 4 | int dummy[] = { | ^~~~~ 0x247a53e internal_error(char const*, ...) ???:0 0xae95dc fancy_abort(char const*, int, char const*) ???:0 0xd09f45 instantiate_decl(tree_node*, bool, bool) ???:0 0xd362db instantiate_pending_templates(int) ???:0 0xbe4555 c_parse_final_cleanups() ???:0 0xe21948 c_common_parse_file() ???:0 Please submit a full bug report, with preprocessed source (by using -freport-bug). Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. Compiler returned: 1 Apparently GCC fails to recognize the `class... Ts` in the angle brackets (new syntax in C++20) as pertaining to the lambda itself, and not to the outer scope. So when GCC sees an unexpanded `Ts` in the inner scope, GCC happily accepts it (and then ICEs). Notice that if you change `Ts()` to `ts` in the inner scope, GCC correctly rejects the code with the usual "parameter packs not expanded" error. The ICE is triggered specifically by misuse of `Ts`-from-the-new-in-C++20-syntax.