Created attachment 47998 [details] Source file to be compiled. The attached file elicits an ICE in the GCC "trunk" version used by Compiler Explorer (https://godbolt.org/z/iPK_JV): ------------ <source>: In function 'int main()': <source>:20:24: internal compiler error: tree check: accessed elt 1 of 'tree_vec' with 0 elts in tsubst_pack_expansion, at cp/pt.c:12765 20 | Foo<bool>::foo<true>(); | ^ Please submit a full bug report, with preprocessed source if appropriate. See <https://gcc.gnu.org/bugs/> for instructions. ------------ When using GCC 9.2, no ICE happens, but the file fails to be parsed: ------------ <source>: In function 'int main()': <source>:20:24: error: no matching function for call to 'Foo<bool>::foo<true>()' 20 | Foo<bool>::foo<true>(); | ^ <source>:11:3: note: candidate: 'template<ARGS ...args> static void Foo<ARGS>::foo() [with ARGS ...args = {args ...}; ARGS = {bool}]' 11 | foo(void) | ^~~ <source>:11:3: note: template argument deduction/substitution failed: <source>:21:31: error: no matching function for call to 'Foo<int, long int>::foo<42, 23>()' 21 | Foo<int, long>::foo<42, 23>(); | ^ <source>:11:3: note: candidate: 'template<ARGS ...args> static void Foo<ARGS>::foo() [with ARGS ...args = {args ...}; ARGS = {int, long int}]' 11 | foo(void) | ^~~ <source>:11:3: note: template argument deduction/substitution failed: <source>:21:31: error: wrong number of template arguments (2, should be 1) 21 | Foo<int, long>::foo<42, 23>(); | ^ <source>:22:34: error: no matching function for call to 'Foo<char, char>::foo<'h', 'i'>()' 22 | Foo<char, char>::foo<'h', 'i'>(); | ^ <source>:11:3: note: candidate: 'template<ARGS ...args> static void Foo<ARGS>::foo() [with ARGS ...args = {args ...}; ARGS = {char, char}]' 11 | foo(void) | ^~~ <source>:11:3: note: template argument deduction/substitution failed: <source>:22:34: error: wrong number of template arguments (2, should be 1) 22 | Foo<char, char>::foo<'h', 'i'>(); | ^ ------------ Clang correctly compiles the file.
The ICE started with r0-128638-gb0ff7fe1d223260aea5b7dc3f36892aa57d43c77 -- a while ago. Before that: 94100.C:19:24: error: no matching function for call to ‘Foo<bool>::foo()’ Foo<bool>::foo<true>(); ^
The following ICEs in a similar fashion: internal compiler error: tree check: accessed elt 2 of 'tree_vec' with 1 elts in tsubst, at cp/pt.c:15334 ### SOURCE: template <typename... T> struct ValListWithTypes { template <T... Members> struct WithVals { using TypeList = ValListWithTypes; }; }; template <typename ValList, typename ValTypeList = typename ValList::TypeList> struct Widget; template <typename ValList, typename... ValTypes> struct Widget<ValList, ValListWithTypes<ValTypes...>> { template <typename = ValList> struct Impl {}; }; template <typename ValList, typename... ValTypes> template <ValTypes... Vals> struct Widget<ValList, ValListWithTypes<ValTypes...>>::Impl< typename ValListWithTypes<ValTypes...>::template WithVals<Vals...>> {}; int main(void) { Widget<ValListWithTypes<int>::WithVals<0>>::Impl<> impl; }