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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code

--- Comment #7 from anlauf at gcc dot gnu.org ---
Refined testcase that shows that scalarization somehow fails for the
assignment:

module mod
  implicit none
  type t1
     integer :: i = 0
  end type t1

  interface assignment(=)
     module procedure sub
  end interface assignment(=)
contains
  elemental subroutine sub(x, y)
    type(t1), intent(inout) :: x
    type(t1), intent(in)    :: y
    x%i = y%i + 42
  end subroutine sub
end module mod

program test
  use mod !, only: t1, assignment(=)
  implicit none
  integer  :: j
  type(t1) :: p(4)
  type(t1) :: q(4) = [(t1(j),j=1,4)]
  integer  :: operm(2) = [2,1]    ! "Output permutation vector"
  integer  :: iperm(2) = [1,2]    ! "Input  permutation vector"
  p%i = -1
  !--
  ! The following two lines give identical -fdump-fortran-original,
  ! but very different -fdump-tree-original:
! call sub (p(operm), q(iperm))   ! works (properly scalarized)
  p(operm) = q(iperm)             ! fails (not correctly scalarized)
  !--
  print *, 'p(1:2)%i =', p(1:2)%i, ' (expect 44 43)'
end program test


When processing the output argument (p(operm)), in gfc_conv_expr_reference
I get in the working case:

10798     if (expr->expr_type == EXPR_VARIABLE)
10799       {
10800         se->want_pointer = 1;
10801         gfc_conv_expr (se, expr);
10802         if (se->post.head)
(gdb) p se->ss->info->data.array->ref
$109 = (gfc_ref *) 0x3a02440

and in the other case:

(gdb) p se->ss->info->data.array->ref
$110 = (gfc_ref *) 0x0

Need an expert's help here.

Reply via email to