[J3] surprisingly PURE

Robert Corbett rpcorbett at att.net
Sat Apr 18 19:12:27 EDT 2020


      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.

Robert Corbett
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20200418/5ded1099/attachment.htm>


More information about the J3 mailing list