Thanks Andrew for the patch and Paul for the test case.

commit b405a04ffde07e9a3021b74a5d40c7938984b88f (HEAD -> master, origin/master, origin/HEAD)
Author: Jerry DeLisle <[email protected]>
Date:   Fri Jan 9 09:38:52 2026 -0800

    Fortran: [PR123483] Fix duplicate finalization

    A duplicated call to a finalizer occured in cases where a derived type
    has components, one or more of which are allocatable, and one or more
    of which are finalizable. (The bug occured only if the derived type
    is an extension of another type, which has defined assignment.)

    New test case derived from the original report by Paul Thomas.

            PR fortran/123483

    gcc/fortran/ChangeLog:

            * trans-array.cc (gfc_deallocate_alloc_comp): Ad the new
            finalization argument and pass it to structure_alloc_comps.
            * trans-array.h (gfc_deallocate_alloc_comp): Add a finalization
            flag that can be passed by gfc_conv_procedure_call.
            * trans-expr.cc (gfc_conv_procedure_call): Use the new
            finalization flag.

    gcc/testsuite/ChangeLog:

            * gfortran.dg/finalize_61.f90: New test.

            Signed off by: Andrew Benson <[email protected]>

Reply via email to