[J3] another PURE example

Robert Corbett rpcorbett at att.net
Mon Oct 5 18:12:33 EDT 2020


      MODULE V
        REAL, TARGET :: X = 1.0
      END

      MODULE PRINT
      USE V
      PRIVATE X
      CONTAINS
        SUBROUTINE PRINTX
          PRINT *, X
        END SUBROUTINE PRINTX
      END

      MODULE T1
        TYPE T
          SEQUENCE
          REAL, POINTER :: P
        END TYPE T
      END

      MODULE T2
      USE V
      PRIVATE X
        TYPE T
          SEQUENCE
          REAL, POINTER :: P => X
        END TYPE T
      END

      PURE SUBROUTINE SUBR
      USE T1
      USE T2, TINIT => T
        TYPE(T) Y
        Y = TINIT()
        Y%P = 2.0
      END

      PROGRAM MAIN
      USE PRINT
        CALL SUBR
        CALL PRINTX
      END
================================================================

I think the program above conforms to the Fortran 2018 standard,
but I am not able to check its conformance.  If anyone sees a
mistake in it, please let me know.

The program is another example of default initialization
breaking the assumptions that underlie the PURE attribute.
It shows that some of the fixes to the definition of PURE
that were proposed in response to my first example are
insufficient.

Because only one compiler was able to compile my first example,
I do not expect most compilers to be able to handle this
program.

I agree with Van that there are problems with the definition of
PURE that go back to the original definition of PURE.  Van also
asserted that the addition of type extensions made the problems
worse, but I do not understand what the additional problems
are.

Robert Corbett





















T
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20201005/c20619bf/attachment-0001.htm>


More information about the J3 mailing list