This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [EXTERNAL] Re: [Patch, F03, RFC] FINAL support in 4.8
- From: "Rouson, Damian" <rouson at sandia dot gov>
- To: "Janus Weil" <janus at gcc dot gnu dot org>
- Cc: "Mikael Morin" <mikael dot morin at sfr dot fr>, "Tobias Burnus" <burnus at net-b dot de>, gfortran <fortran at gcc dot gnu dot org>, "Paul Thomas" <paul dot richard dot thomas at gmail dot com>, "Alessandro Fanfarillo" <fanfarillo dot gcc at gmail dot com>, "Morris, Karla NMN" <knmorri at sandia dot gov>
- Date: Mon, 29 Oct 2012 00:28:01 +0000
- Subject: Re: [EXTERNAL] Re: [Patch, F03, RFC] FINAL support in 4.8
Hi Janus,
In response to one of your questions, the modified version of your test
case below checks the identity of the object being finalized and
determines that "infant" gets finalized, whereas the "new_child()" result
does not. This happens with both the NAG and IBM compilers. Intel
Fortran 12.1 set faults on this example whether I use "class" or "type" in
the declaration in main.
You make good points about the standard. I'll check with NAG on this. It
does seem to me that both infant and new_child() should be finalized.
BTW, please be aware the in ForTrilinos, we carry the inheritance
hierarchies even further so in actual use, there would could be a
grandchild that extends child. Hopefully whatever solution is being
formulated will handle deeper hierarchies.
Damian
$ cat janus-reduced-test.F90
module finalizable_component_module
implicit none
type finalizable_component
logical :: user_defined=.true.
contains
final :: finalize
end type
contains
subroutine finalize(this)
type(finalizable_component) :: this
character(len=18), allocatable :: identity
identity = merge('infant ','new_child()
result',this%user_defined)
print *,'subroutine finalize called on ',identity
end subroutine
end module
module abstract_parent_module
use finalizable_component_module
implicit none
type ,abstract :: abstract_parent
type(finalizable_component) :: foo
end type
end module
module child_module
use abstract_parent_module
implicit none
type, extends(abstract_parent) :: child
end type
contains
type(child) function new_child()
new_child%abstract_parent%foo%user_defined=.true.
end function
end module
program main
use child_module
implicit none
class(child), allocatable :: infant
allocate(infant,source=new_child())
end
$ nagfor janus-reduced-test.F90
NAG Fortran Compiler
[NAG Fortran Compiler normal termination]
$ ./a.out
subroutine finalize called on infant