c++: fix ICE with __type_pack_element [PR113834]
commitf29f7f86935e29786bf9f976ec99d7639b381b14
authorMarek Polacek <polacek@redhat.com>
Fri, 9 Feb 2024 17:03:50 +0000 (9 12:03 -0500)
committerMarek Polacek <polacek@redhat.com>
Fri, 9 Feb 2024 21:40:54 +0000 (9 16:40 -0500)
treeb5c5b33af1b627e104ec6ee250ca2a4b844d2b86
parent3a3e0f1b46a3ad71ebeedc419393e3a36f1ce6db
c++: fix ICE with __type_pack_element [PR113834]

Here we crash on this invalid code because we seem to infinitely recurse
and end up with __type_pack_element with index that doesn't tree_fits_shwi_p
which then crashes on tree_to_shwi.

Thanks to Jakub for suggesting a nicer fix than my original one.

PR c++/113834

gcc/cp/ChangeLog:

* semantics.cc (finish_type_pack_element): Perform range checking
before tree_to_shwi.

gcc/testsuite/ChangeLog:

* g++.dg/ext/type_pack_element4.C: New test.
gcc/cp/semantics.cc
gcc/testsuite/g++.dg/ext/type_pack_element4.C [new file with mode: 0644]