[EXTERNAL] Re: [Patch, F03, RFC] FINAL support in 4.8
Rouson, Damian
rouson@sandia.gov
Mon Oct 29 18:36:00 GMT 2012
Janus,
Everything you stated below about the behavior of the IBM, NAG, and Intel
compilers is correct. The version of Intel's compiler I just tested is
12.1.5.339. I should be able to get access to the Intel's 13.0 release
within a few days.
Damian
On 10/29/12 1:38 AM, "Janus Weil" <janus@gcc.gnu.org> wrote:
>Hi Damian,
>
>> My apologies. The code I sent earlier was wrong in two places (the
>> default initialization and the "merge" call). The corrected version
>>below
>> indicates that NAG (and IBM) finalize the new_child() function result
>>but
>> not "infant". This makes more sense relative to the standard. Item 1 of
>> section 6.7.1.3 of the Fortran 2008 standard suggests that allocating a
>> variable that already has the "allocated" status causes an error
>> condition. If the variable does not already have the "allocated" status
>> (as is the case in this example), then finalizing it makes no sense to
>>me.
>
>yes, concerning the ALLOCATE statement, it makes sense that the result
>of "new_child" should be finalized, and not the "infant" variable.
>Unfortunately our patch currently gets this wrong and finalizes the
>"infant" variable instead (when copying the data from "new_child"
>through the _copy procedure).
>
>In addition, I was wondering whether a finalization of 'infant' at the
>end of the main program should occur (which is what gfortran currently
>does, as a consequence of infant's automatic deallocation, which may
>or may not be what the standard demands).
>
>In summary, for the following program (together with the modules from
>Damian's last test case):
>
>program main
> use child_module
> implicit none
> class(child), allocatable :: infant
> print *,"AAA"
> allocate(infant,source=new_child())
> print *,"BBB"
>end
>
>gfortran currently prints:
>
> AAA
> subroutine finalize called on infant
> BBB
> subroutine finalize called on new_child() result
>
>[The last line does not literally mean that a new_child() result is
>finalized. Instead it comes from the finalization of 'infant' at the
>end of the main program (after it got its value from new_child).]
>
>ifort 12.1.2 segfaults after printing "AAA". If I understand Damian's
>description correctly, IBM and NAG should print
>
> AAA
> subroutine finalize called on new_child() result
> BBB
>
>Cheers,
>Janus
>
More information about the Fortran
mailing list