[J3] surprisingly PURE
Steven G. Kargl
kargl at troutmask.apl.washington.edu
Sat Apr 18 19:38:46 EDT 2020
On Sat, Apr 18, 2020 at 11:12:27PM +0000, Robert Corbett via J3 wrote:
> REAL, TARGET :: X = 1.0
> TYPE T
> REAL, POINTER :: P => X
> END TYPE T
> CALL SUBR
> PRINT *, X
> CONTAINS
> PURE SUBROUTINE SUBR
> TYPE(T) Y
> Y%P = 2.0
> END SUBROUTINE SUBR
> END
> -------------------------------
>
> I think the program given above is standard conformant.
> If it is not standard conformant, please let me know
> why it is not. I know that it should not be standard
> conformant, but I see no reason it is not.
>
> The key point here is that default component
> initialization does not give the variable the SAVE
> attribute. If Y had the SAVE attribute, the program
> would not be conformant.
>
> This program is my third attempt to show this problem.
> My first program was not conformant, and my second did
> not properly demonstrate the problem.
>
Doesn't f2018:C1593(1) apply? I admit I have troubling reading
this section of the Fortran standard.
--
Steve
More information about the J3
mailing list