[Bug fortran/50684] [4.6/4.7 Regression] Incorrect error for move_alloc on element inside intent(in) pointer
burnus at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Oct 12 21:53:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50684
--- Comment #7 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-10-12 21:53:28 UTC ---
(In reply to comment #5)
> I can't give any hard evidence right now, but naively I would say it should
> indeed be rejected. Shouldn't the allocation status of the components be
> protected by the "intent(in)"?
>
> The following (equivalent) variant is at least rejected by gfortran 4.5 on
> upwards:
>
> TYPE MY_TYPE
> INTEGER, ALLOCATABLE :: VALUE
> END TYPE
> CONTAINS
> SUBROUTINE sub (dt)
> type(MY_TYPE), intent(in) :: dt
> deallocate(dt%VALUE)
No, that version is *not* equivalent. In the previous example you have a
*pointer intent*. Those only protect the association status of the dummy - not
the value. -- Pointer intents are a Fortran 2003 feature.
In this example, you have a nonpointer variable. For those, the value (and
hence allocation status) is preserved - including nonpointer components.
Pointer components of intent(in) nonpointer variables may be modified as (or
rather: if) one changes the pointer target and not the pointer itself. --
Nonpointer intents are a Fortran 90 feature.
In any case, the example of comment 5 is clearly invalid.
Cf. also (F2008):
"C539 (R523) A nonpointer object with the INTENT (IN) attribute
shall not appear in a variable definition context (16.6.7)."
"C540 A pointer with the INTENT (IN) attribute shall not appear
in a pointer association context (16.6.8)."
More information about the Gcc-bugs
mailing list