Question about finalization of abstract types
Damian Rouson
damian@rouson.net
Mon Jan 6 06:52:00 GMT 2014
Submitted as PR 59694.
Damian
On Jan 5, 2014, at 6:52 AM, Tobias Burnus <burnus@net-b.de> wrote:
> Hi Damian,
>
> Damian Rouson wrote:
>> I don’t think the following code falls into one of the three categories of cases you listed for which finalization is not yet implemented, but gfortran doesn’t call the final subroutine:
>
> The problem is that gfortran regards "bar" as unused - and never creates the variable:
>
>> block
>> type(foo) :: bar
>> end block
>
> (See also -fdump-tree-original. The the variable isn't created is also problematic with regards to debugging as "pt bar" wouldn't work.)
>
> Try:
>
> block
> type(foo) :: bar
> print *, bar
> end block
>
> which prints:
> ---------------cut--------
>
> Hello from finalizer.
> ---------------cut--------
>
> I think it deserves a PR - and we have to think about how to handle 'unused' variables in general. At least for nonallocatable nonpointer local (-> nonpolymophic) derived-type variables with finalizers, we have to generate the variable. For others (-> debugging) we may (at least for -O0).
>
> Tobias
More information about the Fortran
mailing list