Skip to content

[Flang] Missing finalization call at intrinsic assignment. #113375

@DanielCChen

Description

@DanielCChen

Consider the following test case:

MODULE mDerivedModule

    TYPE :: tTypeDerived(k1)    ! (4)
        INTEGER, KIND :: K1
        INTEGER(4)   :: i
        INTEGER(4) :: j
        CONTAINS
            FINAL :: tTypeDerivedFinal
    END TYPE tTypeDerived

    CONTAINS
        SUBROUTINE tTypeDerivedFinal( o )
            TYPE(tTypeDerived(4)) :: o( :,:,: )
          print*, "in final."
        END SUBROUTINE tTypeDerivedFinal
END MODULE mDerivedModule


PROGRAM allocatedArrayDerived02
    USE mDerivedModule

    INTEGER(4) :: i

    TYPE(tTypeDerived(4)) :: derivedArray( 2,2,2 ) =&
        RESHAPE((/ (tTypeDerived(4)( i,(8 - i) ), i = 1, 8) /), (/ 2,2,2 /))

    TYPE(tTypeDerived(4)), ALLOCATABLE :: derivedArrayAlloc( :,:,: )


    ALLOCATE(derivedArrayAlloc( 3,3,3 ),&
        SOURCE=RESHAPE((/ (tTypeDerived(4)( (27 - i),i ), i = 27, 1, -1) /),&
                                                                (/ 3,3,3 /)))

    derivedArrayAlloc = derivedArray. !!! Finalization should occur here.


END PROGRAM allocatedArrayDerived02

Expected behavior:

a.out
in final

Actual behavior:

a.out

It will work as expected if I

  1. remove the KIND type parameter from the derived type definition, OR
  2. remove the static initialization from the variables.

Metadata

Metadata

Assignees

Labels

bugIndicates an unexpected problem or unintended behaviorflang:runtime

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions