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

--- Comment #3 from anlauf at gcc dot gnu.org ---
(In reply to anlauf from comment #2)
> Potential patch:

This regtests ok.

However,

> Note that we get a (correct) warning for z1 after this fix:
> 
> pr107819-z1.f90:4:10-16:
> 
>     4 |   call s (a(n), a)
>       |          2     1
> Warning: INTENT(OUT) actual argument at (1) might interfere with actual
> argument at (2).

this comes from gfc_check_argument_var_dependency, where we see the INTENT(OUT)
argument a, we see a(n), and here

966           /* In case of elemental subroutines, there is no dependency
967              between two same-range array references.  */
968           if (gfc_ref_needs_temporary_p (expr->ref)
969               || gfc_check_dependency (var, expr, elemental ==
NOT_ELEMENTAL))

gfc_ref_needs_temporary_p (expr->ref) correctly returns true.
The comment sort of does not fit to what happens: the "range" is the same,
but n generates a permutation which is detected by gfc_ref_needs_temporary_p.
But then no temporary is generated for a(n), which means we miss a
corresponding check elsewhere.

Could need help by some expert on this...

Reply via email to