[J3] another PURE example
Brad Richardson
everythingfunctional at protonmail.com
Tue Oct 6 12:45:59 EDT 2020
Am I missing something, or would the following simpler example be sufficient to demonstrate the problem?
MODULE V
REAL, TARGET :: X = 1.0
END
MODULE PRINT
USE V
PRIVATE X
CONTAINS
SUBROUTINE PRINTX
PRINT *, X
END
END
MODULE T_M
TYPE T
REAL, POINTER :: P => X
END
END
PURE SUBROUTINE SUBR
USE T_M
TYPE(T) Y
Y%P = 2.0
END
PROGRAM MAIN
USE PRINT
CALL SUBR
CALL PRINTX
END
Regards,
Brad
On Mon, 2020-10-05 at 22:12 +0000, Robert Corbett via J3 wrote:
> 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/20201006/8864ace1/attachment.htm>
More information about the J3
mailing list