Finalization of allocatable components

Finalization of allocatable components

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

  TYPE :: Thing
    FINAL :: thing_Final
  END TYPE Thing
  TYPE, PUBLIC :: Parent
    TYPE(Thing), ALLOCATABLE :: a_thing
    FINAL :: parent_Final
  END TYPE Parent
  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
PROGRAM final_test
  USE m
  TYPE(Parent), ALLOCATABLE :: a
END PROGRAM final_test

>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 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"
"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 and 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.

Retired 12/31/2016

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.

Retired 12/31/2016

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.]

Retired 12/31/2016

Leave a Comment

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