On Tue, Nov 18, 2025 at 05:51:17PM +0100, Daniele Sahebi wrote:
> Currently, build_over_call calls build_cplus_new in template decls, generating
> a TARGET_EXPR that it then passes to fold_non_dependent_expr, which ends up
> calling tsubst_expr, and since tsubst_expr doesn't handle TARGET_EXPRs, it
> ICEs.
>
> Since there is no way for this code path to be executed without causing an
> ICE, I believe it can be removed.
Thanks for the patch.
Please also add the test from the bug report, and provide a ChangeLog entry for
it (we have a tool for generating the ChangeLog template, if you plan to make
further contributions). It should also have
PR c++/122658
in it.
Please also detail how this patch has been tested.
Looks like Jakub wrote this patch so I'd add
Co-authored-by: Jakub Jelinek <[email protected]>
> ---
> gcc/cp/call.cc | 13 +++----------
> 1 file changed, 3 insertions(+), 10 deletions(-)
>
> diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc
> index f80d597b3394..7985c2d5e1bb 100644
> --- a/gcc/cp/call.cc
> +++ b/gcc/cp/call.cc
> @@ -10328,18 +10328,11 @@ build_over_call (struct z_candidate *cand, int
> flags, tsubst_flags_t complain)
> TREE_NO_WARNING (expr) = true;
> if (immediate_invocation_p (fn))
> {
> - tree obj_arg = NULL_TREE, exprimm = expr;
> + tree obj_arg = NULL_TREE;
> if (DECL_CONSTRUCTOR_P (fn))
> obj_arg = first_arg;
> - if (obj_arg
> - && is_dummy_object (obj_arg)
> - && !type_dependent_expression_p (obj_arg))
> - {
> - exprimm = build_cplus_new (DECL_CONTEXT (fn), expr, complain);
> - obj_arg = NULL_TREE;
> - }
> /* Look through *(const T *)&obj. */
> - else if (obj_arg && INDIRECT_REF_P (obj_arg))
> + if (obj_arg && INDIRECT_REF_P (obj_arg))
> {
> tree addr = TREE_OPERAND (obj_arg, 0);
> STRIP_NOPS (addr);
> @@ -10351,7 +10344,7 @@ build_over_call (struct z_candidate *cand, int flags,
> tsubst_flags_t complain)
> obj_arg = TREE_OPERAND (addr, 0);
> }
> }
> - fold_non_dependent_expr (exprimm, complain,
> + fold_non_dependent_expr (expr, complain,
> /*manifestly_const_eval=*/true,
> obj_arg);
> }
> --
> 2.47.3
>
Marek