Finalizer with allocatable components

Finalizer with allocatable components

Hello,

I am trying to understand how finalizers work in Fortran.

I have written a minimal test program containing a derived type with just a final procedure and an allocatable component.

It appears that the finalizer is called more that once, and I don't understand why.

I noticed this behaviour only if the derived type contains an allocatable component, and if more than one object is instantiated from that class.

Here is the code :

module finalizer_module
implicit none
type :: obj
    real,allocatable :: var
    contains
        final :: clean
end type
contains
    subroutine clean(this)
    type(obj) :: this
        write(*,*) "in finalizer"
    end subroutine clean
end module finalizer_module
!
program test_finalizer
use :: finalizer_module
    call sub
contains
    subroutine sub
    type(obj) :: f1,f2
    end subroutine sub
end program test_finalizer

And here the output :

 in finalizer
 in finalizer
 in finalizer

I think I should have only two "in finalizer", as I have two objects (f1,f2) that are destroyed at "end subroutine sub"?

NB:

$ ifort --version
ifort (IFORT) 14.0.2 20140120

 

9 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
Best Reply

At first glance this appears to be ether the same bug or a related one to the one reported in http://software.intel.com/en-us/forums/topic/487145  For now I'm going to assume it's the same but will add your test case to it - issue ID is DPD200249474.

Retired 12/31/2016

Ok, I hadn't found this previous thread...

Is there a public website available to follow the evolution of ifort issues ?

Quote:

Simon wrote:

Ok, I hadn't found this previous thread...

Is there a public website available to follow the evolution of ifort issues ?

Yes, it'll be nice if such a site were available..

This is the site. Any developments are added to the forum threads where the issue was reported.

Retired 12/31/2016

Steve,

What I think would be helpful would be to have a Sticky thread listing the Issue ID's, summary, status, what version fixed issue, and links back to the forum messages that relate to the issue. This would be immensely useful as a self-help tool.

Jim Dempsey

www.quickthreadprogramming.com

Jim, the "summary" is perhaps the hardest part of that. I know from my many years of writing release notes that it is sometimes difficult if not impossible to come up with a concise summary of a particular problem. (Especially when the symptom is Internal Compiler Error.) Even if one could write a summary, it can mislead people into thinking they have the same problem and they won't report it. We'd much rather you report a duplicate than decide you don't need to report a problem. Often new reports of what looks like the identical problem are in fact something else entirely.

Retired 12/31/2016

Steve,

Perhaps you and Intel staff can look at this site which lists all the open issues with gfortran.  Something similar for Intel Fortran will be very helpful.  As Jim suggests, one good add would be links to any forum topics that connect to the issues.

Thanks,

The reported problem is fixed in 15.0.

Retired 12/31/2016

Leave a Comment

Please sign in to add a comment. Not a member? Join today