(j3.2006) (SC22WG5.3966) question about deallocation
Reinhold Bader
Reinhold.Bader at lrz.de
Sat Mar 28 07:01:29 EDT 2009
Hello,
Robert Corbett schrieb:
> Consider the code fragment
>
> MODULE M
> . . .
> TYPE BASE
> INTEGER I
> CONTAINS
> FINAL SUBR1
> END TYPE
> TYPE, EXTENDS(BASE) :: EXTENDED
> CONTAINS
> FINAL SUBR2
> END TYPE
> . . .
> END MODULE
>
> PROGRAM MAIN
> USE M
> TYPE(EXTENDED), POINTER :: P
> TYPE(BASE), POINTER :: Q
> . . .
> ALLOCATE(P)
> Q => P%BASE
> . . .
> DEALLOCATE(Q)
> . . .
> END
>
> Is the DEALLOCATE statement standard conforming?
I think it isn't. Clause 6.3.3.2 of the 2003 standard says that
"If a pointer appears in a DEALLOCATE statement, it shall be associated
with the whole of an object
that was created by allocation."
Surely this rule is also applicable for the case of type extension.
Regards
> If so,
> are both final subroutines invoked, or is only SUBR1
> invoked? The implementation of deallocation in Sun
> Fortran can easily be extended to support either
> semantics.
>
> Bob Corbett
> _______________________________________________
> J3 mailing list
> J3 at j3-fortran.org
> http://j3-fortran.org/mailman/listinfo/j3
>
More information about the J3
mailing list