J3/05-177
Date: 25 Apr 2005
To: J3
From: Rob James
Subject: Finalization of array constructors
NUMBER:
TITLE: Finalization of array constructors
KEYWORDS: Finalization, array constructor
DEFECT TYPE:
STATUS: J3 consideration in progress
QUESTION:
Consider the following program:
MODULE m
TYPE t
INTEGER i
CONTAINS
FINAL :: finalizeT
END TYPE
CONTAINS
SUBROUTINE finalizeT(obj)
TYPE(t) :: obj(:)
PRINT *, 'Finalizing a rank-1 array of type t'
END SUBROUTINE
END MODULE
PROGRAM foo
USE m
TYPE(t) :: a
a%i = 5
PRINT *, (/ (a, i=1,5) /)
END PROGRAM
If the PRINT statement in the main program was printing a function
result or a structure constructor, rather than an array constructor,
it is clear that the object should be finalized after that PRINT
statement.
However, for array constructors, this does not appear to be the case.
In the main program above, should the entity created by the array
constructor be finalized after execution of the PRINT statement?
ANSWER:
Yes, the array constructor should be finalized. Edits are provided to
correct this oversight.
EDITS:
All edits refer to 04-007.
[59:28+] Add a new paragraph:
If an executable construct references an array constructor, the
entity created by the array constructor is finalized after
execution of the innermost executable construct containing the
reference.
[59:31-] Add a new paragraph:
If a specification expression in a scoping unit references an
array constructor, the entity created by the array constructor is
finalized before execution of the executable constructs in the
scoping unit.
SUBMITTED BY: Rob James
HISTORY: 05-177 m172 Submitted