https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94100

            Bug ID: 94100
           Summary: ICE: tree check: accessed elt 1 of 'tree_vec' with 0
                    elts in tsubst_pack_expansion, at cp/pt.c:12765
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jjk at acm dot org
  Target Milestone: ---

Created attachment 47998
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=47998&action=edit
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.

Reply via email to