c++: another build_new_1 folding fix [PR111929]
commit6ff8b93c7b0bf3913fb7754f9985e7e31c46d89c
authorPatrick Palka <ppalka@redhat.com>
Fri, 27 Oct 2023 15:31:02 +0000 (27 11:31 -0400)
committerPatrick Palka <ppalka@redhat.com>
Fri, 27 Oct 2023 15:31:02 +0000 (27 11:31 -0400)
tree488c41a8ba24ac5fde8d26b7649a8f58e369eba2
parent68e97c5442ebb1c47bde77e82ac8a0e823347eb1
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.
gcc/cp/init.cc
gcc/testsuite/g++.dg/template/non-dependent28a.C [new file with mode: 0644]