https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123660

--- Comment #6 from Boris Staletic <boris.staletic at protonmail dot com> ---
(In reply to Boris Staletic from comment #5)
> Previous patch was bad, but this one fixes this bug, pr-123661 and another
> similar case.
> 
> ```
> diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
> index 1ee8e2fff7..97afc78519 100644
> --- a/gcc/cp/pt.cc
> +++ b/gcc/cp/pt.cc
> @@ -21447,8 +21447,28 @@ tsubst_expr (tree t, tree args, tsubst_flags_t
> complain, tree in_decl)
>         op1 = tsubst_qualified_id (op1, args, complain, in_decl,
>                                    /*done=*/true, /*address_p=*/true);
>        else
> -       op1 = tsubst_non_call_postfix_expression (op1, args, complain,
> -                                                 in_decl);
> +       {
> +         tree old_op1 = op1;
> +         op1 = tsubst_non_call_postfix_expression (op1, args, complain,
> +                                                   in_decl);
> +         if (TREE_CODE (old_op1) == SPLICE_EXPR)
> +           {
> +             if (TREE_CODE (op1) == BASELINK)
> +               {
> +                 tree fn = MAYBE_BASELINK_FUNCTIONS (op1);
> +                 if (TREE_CODE (fn) == FUNCTION_DECL &&
> +                     TREE_CODE (TREE_TYPE (op1) ) == METHOD_TYPE &&
> +                     !TREE_STATIC (op1))
> +                   op1 = fn;
> +               }
> +             if (TREE_CODE (op1) == FIELD_DECL ||
> +                 (TREE_CODE (op1) == FUNCTION_DECL &&
> +                  TREE_CODE (TREE_TYPE (op1)) == METHOD_TYPE &&
> +                  !TREE_STATIC (TREE_TYPE (op1))))
> +               op1 = build_offset_ref(DECL_CONTEXT(op1), op1, true,
> complain);
> +           }
> +
> +       }
>        RETURN (build_x_unary_op (input_location, ADDR_EXPR, op1,
>                                 templated_operator_saved_lookups (t),
>                                 complain|decltype_flag));
> ```
> 
> Honestly, this patch looks ugly and I still don't really understand what
> BASELINK is.
> Here's a godbolt link to the bigger test case that I was trying to get to
> work:
> https://godbolt.org/z/fo4hbW7rf

I have made a pull request with this patch (and a proper test case):
https://gcc.gnu.org/pipermail/gcc-patches/2026-February/707942.html

Reply via email to