[Bug fortran/44879] New: MOVE_ALLOC rejects FROM= which is a function result

burnus at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Thu Jul 8 22:04:00 GMT 2010


>From Reinhold Bader at http://j3-fortran.org/pipermail/j3/2010-July/003653.html

The following program is rejected with:

  call move_alloc(extd(i1), i1)
                  1
Error: 'from' argument of 'move_alloc' intrinsic at (1) must be a variable


The standard does not say anything about "variable":
"FROM may be of any type and rank. It shall be allocatable. It is an INTENT
(INOUT) argument."

The check is done at gfc_check_move_alloc. It might be sufficient to replace:

  if (variable_check (from, 0) == FAILURE)
    return FAILURE;
by
  if (from->expr_type != EXPR_VARIABLE && ... != EXPR_FUNCTION)
    { gfc_error ...; return FAILURE }

The rest (e.g. gfc_variable_attr) can deal with it.


program mvall_01
  implicit none
  integer, parameter :: n1 = 100, n2 = 2*n1
  integer, allocatable :: i1(:)

  allocate(i1(n1))
  i1 = 1
  call move_alloc(extd(i1), i1)
  print *, i1(1), size(i1)
  if (i1(1) /= 2 .or. size(i1) /= 200) call abort()
contains
  function extd(in) result(out)
    integer, allocatable :: out(:)
    integer, intent(in) :: in(:)
    allocate(out(2*size(in)))
    out = 2
  end function
end program


-- 
           Summary: MOVE_ALLOC rejects FROM= which is a function result
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44879



More information about the Gcc-bugs mailing list