[J3] Clarification on F18/017
Ondřej Čertík
ondrej at certik.us
Thu Jun 4 14:48:30 EDT 2020
Hi,
We have a question for the interpretation F18/017. As it was submitted for vote, and if the edits are done to the standard, what is the expected result of the program that I am attaching below? See the issue https://github.com/j3-fortran/fortran_proposals/issues/146 for more context and background.
1. Our understanding is that the new standard would preclude multiple finalization of A (which is good), but would allow the compiler to implement any of CABP, CBAP, and CBPA call orders.
2. A program could force CABP by explicitly deallocating the allocatable component in the final procedure for the containing object.
Is both 1. and 2. correct?
Thanks,
Ondrej
----------------
module child_type
implicit none
private
type :: objectA
contains
final :: finalize_objectA
end type
type :: objectB
contains
final :: finalize_objectB
end type
type :: parent
contains
final :: finalize_parent
end type
type, extends(parent), public :: child
type(objectA), allocatable :: A
type(objectB) :: B
contains
procedure :: init
final :: finalize_child
end type
contains
subroutine finalize_objectA(this)
type(objectA), intent(inout) :: this
write(*,'("A")',advance='no')
end subroutine
subroutine finalize_objectB(this)
type(objectB), intent(inout) :: this
write(*,'("B")',advance='no')
end subroutine
subroutine finalize_parent(this)
type(parent), intent(inout) :: this
write(*,'("P")',advance='no')
end subroutine
subroutine finalize_child(this)
type(child), intent(inout) :: this
write(*,'("C")',advance='no')
end subroutine
subroutine init(this)
class(child), intent(inout) :: this
allocate(this%A)
end subroutine
end module
program main
use child_type
call run
contains
subroutine run
type(child) :: c
call c%init
end subroutine
end program
More information about the J3
mailing list