https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113834
--- Comment #9 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Marek Polacek <mpola...@gcc.gnu.org>: https://gcc.gnu.org/g:f29f7f86935e29786bf9f976ec99d7639b381b14 commit r14-8904-gf29f7f86935e29786bf9f976ec99d7639b381b14 Author: Marek Polacek <pola...@redhat.com> Date: Fri Feb 9 12:03:50 2024 -0500 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.