On Mon, Sep 19, 2022 at 9:31 AM Mikael Morin <morin-mik...@orange.fr> wrote: > > Le 18/09/2022 à 12:48, Richard Biener a écrit : > > > >> Does *(&a[1]) count as a pointer dereference? > > > > Yes, technically. > > > >> Even in the original dump it is already simplified to a straight a[1]. > > > > But this not anymore. The check can probably be relaxed, it stems from the > > dual purpose of CLOBBER. > > > So the following makes the frontend-emitted IL valid, by handing the > simplification over to the middle-end, but I can't help thinking that > behavior won't be more reliable.
I think that will just delay the folding. We are basically relying on the frontends to restrict what they produce, the *ptr case was specifically for C++ this in CTOR/DTORs and during inlining we throw away all clobbers that end up "wrong" but I guess we might have latent issues when we obfuscate the address in the caller enough and get undesired simplification ... > > diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc > index f8fcd2d97d9..5fb9a3a536d 100644 > --- a/gcc/fortran/trans-expr.cc > +++ b/gcc/fortran/trans-expr.cc > @@ -6544,8 +6544,9 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * > sym, > && !sym->attr.elemental) > { > tree var; > - var = build_fold_indirect_ref_loc (input_location, > - parmse.expr); > + var = build1_loc (input_location, INDIRECT_REF, > + TREE_TYPE (TREE_TYPE > (parmse.expr)), > + parmse.expr); > tree clobber = build_clobber (TREE_TYPE (var)); > gfc_add_modify (&clobbers, var, clobber); > } >