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

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The problem is that some expressions are genericized twice.
First when genericizing the whole function, RESULT_DECL is determined to be
is_invisiref_parm and therefore references to it are turned into INDIRECT_REF
around it and the RESULT_DECL becomes REFERENCE_TYPE.
Later on gimplify_body calls unshare_body and unshares the INDIRECT_REF.
Then the INDIRECT_REF is gimplified into a MEM_REF.  And finally:
(cp_gimplify_expr) <case VEC_INIT_EXPR> does:
625             cp_walk_tree (expr_p, cp_fold_r, &pset, NULL);
626             cp_genericize_tree (expr_p);
and sees the is_invisiref_parm RESULT_DECL again (inside of MEM_REF) and turns
it again into INDIRECT_REF and that is later gimplified again into MEM_REF.  So
we have 2 nested MEM_REFs, so one indirection too many.

I think one possibility would be to be careful about REFERENCE_REF_Ps and
corresponding MEM_REFs (I guess would need to double check that the offset is 0
and type is compatible with the type of the reference), if their argument is
is_invisiref_parm, ensure it isn't convert_from_reference again.  Will try to
implement that now.

Reply via email to