[Bug fortran/50684] [4.6/4.7 Regression] Incorrect error for move_alloc on element inside intent(in) pointer

janus at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Oct 12 20:45:00 GMT 2011


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

--- Comment #3 from janus at gcc dot gnu.org 2011-10-12 20:44:27 UTC ---
(In reply to comment #1)
> 
> That won't work for:
> 
>  type(t), intent(in) :: dt
>  call move_alloc(dt%allocatable, ...)
> 
> That's invalid as dt%allocatable is intent(in);


I have to admit that I hadn't really thought about this comment yet, but now
that I do, I think the patch actually works for this case, assuming you mean
the following:


  TYPE MY_TYPE
    INTEGER, ALLOCATABLE :: VALUE
  END TYPE

CONTAINS

  SUBROUTINE sub (dt)
    type(MY_TYPE), intent(in) :: dt
    INTEGER, ALLOCATABLE :: lv
    call move_alloc(dt%VALUE, lv)
  END SUBROUTINE

end


This was rejected before, and still is with my patch.

The reasoning of the patch is that one should only throw the error for
intent(in) pointers, if they are passed on without any sub-references, which I
would say is correct.



More information about the Gcc-bugs mailing list