Deallocation on Intrinsic Assignment


How many finalizations I should expect with these two test cases?

The above tests an intrinsic assignment where the LHS has an allocatable
finalizable component. Both the LHS and RHS have the same RunTime Type.

There are more test cases in that gist. Having feedback for them also would be
nice. Currently, I’m stuck with the particular two (realloc_class_8.f90 & realloc_class_9.f90 ).

Ev. Drikos

@drikosev ,

Welcome to this Discourse, glad you followed up on the suggestion at comp.lang.fortran and decided to post here as well.

Hopefully you will soon get wider feedback on your inquiry. Note with your cases, you may face the TL;DR issue. So anything you can do to make your cases short and sweet might pique more interest.

As to your question, based on my understanding of the current standard, I personally expect the following:

  1. realloc_class_8.f90 case: 4 finalizations, 2 each for your objects v and x upon exiting your subroutine s.

  2. realloc_class_9.f90 case: 6 finalizations, 2 each for your objects v, x, and w upon exiting your subroutine s.

That is, no finalizations during the assignments v = x and v = w in these 2 cases respectively.

1 Like


Indeed, the test cases are somewhat long, also not the usual case in the GNU Fortran testsuite. One reason was uncertainty about the results. Another reason may become more obvious by a comment in realloc_class_3-f90 (! Check any bug that may execute the finalizer of the RHS).

So I was facing problems of that form. The wrong results of “realloc_class_9.f90” may be a new PR in GNU Bugzilla. Your feedback is really appreciated.

Ev. Drikos