]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: ICE with pack indexing empty pack [PR117898]
authorMarek Polacek <polacek@redhat.com>
Wed, 4 Dec 2024 21:58:59 +0000 (16:58 -0500)
committerMarek Polacek <polacek@redhat.com>
Fri, 6 Dec 2024 01:12:02 +0000 (20:12 -0500)
commitafeef7f0d3537cd978931a5afcbd3d91c144bfeb
treedcafb1e30d048679d9ce1cc193be1cc701a706f5
parent3ac3093756cd00f50e63e8dcde4d278606722105
c++: ICE with pack indexing empty pack [PR117898]

Here we ICE with a partially-substituted pack indexing.  The pack
expanded to an empty pack, which we can't index.  It seems reasonable
to detect this case in tsubst_pack_index, even before we substitute
the index.  Other erroneous cases can wait until pack_index_element
where we have the index.

PR c++/117898

gcc/cp/ChangeLog:

* pt.cc (tsubst_pack_index): Detect indexing an empty pack.

gcc/testsuite/ChangeLog:

* g++.dg/cpp26/pack-indexing2.C: Adjust.
* g++.dg/cpp26/pack-indexing12.C: New test.
gcc/cp/pt.cc
gcc/testsuite/g++.dg/cpp26/pack-indexing12.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp26/pack-indexing2.C