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

--- Comment #5 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
Fixing the dependency for identical=true is a Good Thing(TM), but
will not be enough to fix the test case:

$ cat bar.f90
program main
  implicit none
  real, dimension(3,3,3) :: f,g
  integer :: three
  call random_number(f)
  three = 3
  g(1, 1:three, :) = matmul(f(2,1:3,2:3), f(3,2:3,:))
  print *, g(1,1:3,:)
end program main
$ gfortran -Warray-temporaries bar.f90
bar.f90:7:21:

    7 |   g(1, 1:three, :) = matmul(f(2,1:3,2:3), f(3,2:3,:))
      |                     1
Warnung: Zwischenergebnis-Feld bei (1) wird erzeugt [-Warray-temporaries]

The code in question, in gfc_conv_procedure_call, is

          /* Create a temporary to store the result.  In case the function
             returns a pointer, the temporary will be a shallow copy and
             mustn't be deallocated.  */
          callee_alloc = comp->attr.allocatable || comp->attr.pointer;
          gfc_trans_create_temp_array (&se->pre, &se->post, se->ss,
                                       tmp, NULL_TREE, false,
                                       !comp->attr.pointer, callee_alloc,
                                       &se->ss->info->expr->where);

We should special-case the case of result = function(...) here.

Reply via email to