(j3.2006) finalizing undefined entities -- odd text in 6.6.4

Jim Xia jimxia
Tue Mar 18 21:20:13 EDT 2008


j3-bounces at j3-fortran.org wrote on 03/18/2008 05:03:35 PM:

> Really??  My interpretation has been that including the stat= specifier 
> should prevent the program from aborting.
> 

It would be really useful if it does.  Try this program to see if stat= 
does do magic :-)


    real, pointer :: a, b
 
    allocate (a)
 
    b => a
 
    deallocate (b, stat=i1)
 
    deallocate(a, stat=i2)
 
    print *, i1, i2
    end


Due to the introduction of finalization in Fortran 2003, I would imagine 
some users will end up doing this in their code without any knowledge of 
its occurrence.  If you have pointer components and two structures appear 
in intrinsic assignments, then we got pointer assignment effectively 
taking place for the pointer components.  And the finalizer can be invoked 
for two structures sharing the same address.  The net effect is identical 
to the shown case.  It may boil down to what OS is your program run on and 
how lucky you are when the freed memory is reclaimed by the operating 
system, etc.  On AIX, the program tells me both ALLOCATE statements run 
successfully and on Linux, it persistently generates SIGABRT.  I don't 
think Fortran language would ever dare to say stat= will prevent bad thing 
from happening, as you just found out in the standard.

Have fun with the finalization ...

Cheers,


Jim Xia

RL Fortran Compiler Test
IBM Toronto Lab at 8200 Warden Ave, Markham, On, L6G 1C7
Phone (905) 413-3444  Tie-line 313-3444
email: jimxia at ca.ibm.com
D2/YF7/8200 /MKM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://j3-fortran.org/pipermail/j3/attachments/20080318/bd74982e/attachment.html 



More information about the J3 mailing list