Finalization of allocatable components

Finalization of allocatable components

Allocatable components are not being finalized when their parent object is deallocated?

MODULE m
  IMPLICIT NONE
  
  TYPE :: Thing
  CONTAINS
    FINAL :: thing_Final
  END TYPE Thing
  
  TYPE, PUBLIC :: Parent
    TYPE(Thing), ALLOCATABLE :: a_thing
  CONTAINS
    FINAL :: parent_Final
  END TYPE Parent
CONTAINS
  SUBROUTINE thing_Final(obj)
    TYPE(Thing), INTENT(INOUT) :: obj
    PRINT *, 'Component final'
  END SUBROUTINE thing_Final
  
  SUBROUTINE parent_Final(obj)
    TYPE(Parent), INTENT(INOUT) :: obj
    PRINT *, 'Parent final'
  END SUBROUTINE parent_Final
END MODULE m
PROGRAM final_test
  USE m
  IMPLICIT NONE
  TYPE(Parent), ALLOCATABLE :: a
  ALLOCATE(a)
  ALLOCATE(a%a_thing)
  DEALLOCATE(a)
END PROGRAM final_test

[U:projectsFortranMiscFortranMisc]
>ifort /check:all /warn:all /standard-semantics "2013-01-29 final.f90" && "2013-01-29 final.exe"
Intel(R) Visual Fortran Compiler XE for applications running on IA-32, Version 13.0.1.119 Build 20121008
Copyright (C) 1985-2012 Intel Corporation.  All rights reserved.
2013-01-29 final.f90(20): remark #7712: This variable has not been used.   [OBJ]
  SUBROUTINE parent_Final(obj)
--------------------------^
2013-01-29 final.f90(15): remark #7712: This variable has not been used.   [OBJ]
  SUBROUTINE thing_Final(obj)
-------------------------^
Microsoft (R) Incremental Linker Version 10.00.40219.01
Copyright (C) Microsoft Corporation.  All rights reserved.
"-out:2013-01-29 final.exe"
-subsystem:console
"2013-01-29 final.obj"
 Parent final

In the above the parent object is finalizable, but I think even if it wasn't (no final:: parent_Final statement) the finalizer for a%a_thing should still be called.  Mentioned previously in http://software.intel.com/en-us/forums/topic/278463 and http://software.intel.com/en-us/forums/topic/284434 and possibly in other threads, so perhaps this is all well known, but I couldn't find a definitive issue id.

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

Odd... I think Mr Forum Software is playing silly games.  I see a "The breadcrumb insertion has been deleted." message in the header and the post doesn't show up in the forum post list.  Perhaps I'm talking to myself.  Oh well, in that case "How's the family?"  "They're fine, thanks.", etc.

Edit to note that the post appeared in the list perhaps almost a day later?

I've seen that "breadcrumb" message - it can be ignored.  The developers are looking at that.

I will look into your question here.I recall having a discussion with one of the developers on this topic just recently, so it may be a bug being worked on already.

Steve - Intel Developer Support

This one astonishes me - it seems so clear from the standard to me.  I have escalated it as issue DPD200240676. I looked at the other threads and they may be related - I'll look at those closer.

Steve - Intel Developer Support

I expect this problem to be fixed in Update 5 (late June).

[Edit - we renumbered the updates, so this fix is now planned for Update 5 - same timeframe.]

Steve - Intel Developer Support

Login to leave a comment.