https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118120
--- Comment #10 from kargls at comcast dot net --- (In reply to anlauf from comment #9) > (In reply to kargls from comment #8) > > (In reply to anlauf from comment #7) > > > The following patch works and might be a reasonable compromise: > > > > > > diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc > > > index 82a2ae1f747..985a26281ad 100644 > > > --- a/gcc/fortran/trans-array.cc > > > +++ b/gcc/fortran/trans-array.cc > > > @@ -5345,7 +5345,10 @@ symbols_could_alias (gfc_symbol *lsym, gfc_symbol > > > *rsym, bool lsym_pointer, > > > bool lsym_target, bool rsym_pointer, bool > > > rsym_target) > > > { > > > /* Aliasing isn't possible if the symbols have different base types. > > > */ See below. You need to update the comment to reflect that the symbols can have different base types. > > > - if (gfc_compare_types (&lsym->ts, &rsym->ts) == 0) > > > + if (!gfc_compare_types (&lsym->ts, &rsym->ts) > > > + && !(((lsym->ts.type == BT_COMPLEX && rsym->ts.type == BT_REAL) > > > + || (lsym->ts.type == BT_REAL && rsym->ts.type == BT_COMPLEX)) > > > + && lsym->ts.kind == rsym->ts.kind)) > > > return 0; > > > > > > /* Pointers can point to other pointers and target objects. */ > > > > I think it is more complicated in that this involves pointers, which > > have an aliasing issue (due to bounds remapping). In an ordinary assignment > > one has 'var = expr', and in Slava example that is exactly what we have > > where 'result' and 'temp' are pointers into parts of 'data%re'. But, > > 'data%re' could have been any type compatible entity. The big hammer, > > until the mythical someone shows up, is > > > > diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc > > index 82a2ae1f747..abebf327621 100644 > > --- a/gcc/fortran/trans-array.cc > > +++ b/gcc/fortran/trans-array.cc > > @@ -5503,6 +5503,20 @@ gfc_conv_resolve_dependencies (gfc_loopinfo * loop, > > gfc_ss * dest, > > loop->temp_ss = NULL; > > dest_expr = dest->info->expr; > > > > + /* Before falling into dependency checking of the scalarization, > > + check to see if the left-hand variable is an array pointer. If > > + it is, simply generate an array temporary for the assignment. > > + TODO: walk the right-hand-side of 'var = expr' to actually check > > + for a dependency. See 118120. */ > > + if (dest_expr->symtree && dest_expr->symtree->n.sym > > + && dest_expr->symtree->n.sym->attr.pointer > > + && dest_expr->symtree->n.sym->attr.dummy > > + && dest_expr->symtree->n.sym->attr.dimension) > > + { > > + nDepend = 1; > > + goto temporary; > > + } > > + > > for (ss = rss; ss != gfc_ss_terminator; ss = ss->next) > > { > > ss_info = ss->info; > > I doubt that this is a good solution. > > It is completely irrelevant that "result" is a dummy. Just try it. > And creating a temporary for *every lhs pointer* cannot be acceptable. > There must be something more "lightweight". I agree it's not the best solution. This is why I called it a 'big hammer'. Checking for a dummy argument is simply trying to reduce the biggest of the hammer. I suspect the aliasing issue is more likely to occur through argument association, but users can be creative. Feel free to pursue your patch with an expanded comment.