fortran 7.1 Final routine oddites

William Clodius w.clodius@icloud.com
Sun Mar 25 00:09:00 GMT 2018


My appollogies. It is obvious that I had not understood the implications of INTENT(OUT) on my initialization routine. With that intent the object on entry is destroyed, which implies that the finalizer will be invoked, which implies that the finalizer will be invoked on an uninitialized object. The code in my finalizer must be ugly to deal with that reality, but it makes the overall use of the code cleaner.I believe that gfortran is standard conforming.

> On Mar 24, 2018, at 5:21 PM, Steve Kargl <sgk@troutmask.apl.washington.edu> wrote:
> 
> On Sat, Mar 24, 2018 at 04:54:23PM -0600, William Clodius wrote:
>> I have been experimenting with object orientation in Fortran.
>> I recently developed a derived type for which a final routine
>> seemed appropriate. I have been testing the code using gfortran
>> 7.1. Its introduction in testing immediately caused problems.
>> In the most recent test it caused a SIGSEGV. It was being invoked
>> before the type components had been initialized, and attempting
>> to index an unallocated array. I suspect, but have not verified,
>> that it was being invoked on an allocate statement. I have been
>> able to work my way around it by testing for array allocation
>> and pointer association, before attempting indexing, deallocation,
>> etc, but the result is ugly code. It will be a pain to reduce the
>> code to a simple test case, but I will if it is useful. Is this
>> a known problem with gfortran 7.1, and has it been fixed?
> 
> There a few open bug reports about finalization.  You
> find a list by going to the gfortran wiki, scan down
> to the 'All reports' link, and clicking.  This shows
> the most recent 500 PRs.  From there you can get a list
> of all open PRs (911 at the moment :-(.  See
> 
> 84472 --- Missing finalization and memory leak 
> 82996 --- ICE and segfault with derived type finalization 
> 80524 --- [F03] Problematic behaviour with a finalization
>          subroutine in gfortran 
> 71798 --- [OOP] failure to finalise temporary 
> 70863 --- [F03] Finalization of array of derived type causes segfault 
> 69298 --- [OOP] Array finalisers seem to be given the wrong array
>          when the array is a member variable 
> 68778 --- [F03] Missing default initialization of finalized derived
>          types type(C_PTR) component in subroutines 
> 67471 --- [F03] Finalizer not invoked for assignment to array section
> 67444 --- [F03] RHS in assignment of polymorphic types not finalized
> 65347 --- [F03] Final subroutine not called for function result 
> 64290 --- [F03] No finalization at deallocation of LHS
> 59694 --- [F03] no finalization of an unused variable 
> 37336 --- [F03] Finish derived-type finalization 
> 
> Unfortunately, there are too people working on gfortran, and
> especially too few who know anything about finalization.
> 
> -- 
> Steve



More information about the Fortran mailing list