https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111929
--- Comment #12 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Patrick Palka <ppa...@gcc.gnu.org>: https://gcc.gnu.org/g:6ff8b93c7b0bf3913fb7754f9985e7e31c46d89c commit r14-4979-g6ff8b93c7b0bf3913fb7754f9985e7e31c46d89c Author: Patrick Palka <ppa...@redhat.com> Date: Fri Oct 27 11:31:02 2023 -0400 c++: another build_new_1 folding fix [PR111929] In build_new_1, we also need to avoid folding 'outer_nelts_check' when in a template context to prevent an ICE on the below testcase. This patch replaces the problematic fold_build2 call with build2 (we'll later fold it if appropriate during cp_fully_fold). In passing, this patch removes an unnecessary conversion of 'nelts' since it should always already be a size_t (and 'convert' isn't the best conversion entry point to use anyway since it lacks a complain parameter). PR c++/111929 gcc/cp/ChangeLog: * init.cc (build_new_1): Remove unnecessary call to convert on 'nelts'. Use build2 instead of fold_build2 for 'outer_nelts_checks'. gcc/testsuite/ChangeLog: * g++.dg/template/non-dependent28a.C: New test.