Skip to content

[Flang] Unexpected runtime I/O error related to finalization #126264

Open
@DanielCChen

Description

@DanielCChen

Consider the following code

module m
    type base
        integer*4 :: id

        contains

        procedure :: makeArray => createBaseArray
        final :: finalizeBaseRank1
    end type

    type (base) :: b1_m

    contains

    function createBaseArray (b, n)
        class (base), intent(in) :: b
        integer*4, intent(in) :: n
        class (base), allocatable :: createBaseArray (:)

        allocate (createBaseArray(n))

        createBaseArray%id = b%id
    end function

    subroutine finalizeBaseRank1 (b)
        type(base) :: b(:)

        print *, 'finalizeBaseRank1'
    end subroutine

end module

program ftpbnd516a
use m
  print*, size (b1_m%makeArray (3))
end

Flang currently issues a runtime I/O error as:

> a.out

fatal Fortran runtime error(/home/cdchen/temp/t.f:28): Recursive I/O attempted on unit 6
 3IOT/Abort trap(coredump)

It seems the print statement in the main program got interfered with the print statement in the finalization routine.
All ifort, gfortran and XLF executed the program successfully.

Metadata

Metadata

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions