Skip to content

[flang][runtime] Flang allows different unit number in child I/O #157543

@DanielCChen

Description

@DanielCChen

Consider the following code:

module m
    type base
        integer(4), pointer :: i
    end type

    integer(4), parameter :: ISNULL = -999999
end module


program fdtio504a1
use m

    interface write(unformatted)
        subroutine unformattedWrite (dtv, unit, iostat, iomsg)
        import base
            class (base), intent(in) :: dtv
            integer, intent(in) :: unit
            integer, intent(out) :: iostat
            character(*), intent(inout) :: iomsg
        end subroutine
    end interface

    integer stat
    character(8) :: errormsg

    open (1, file='fdtio504a1.data', form='unformatted')

    write (1, iostat=stat, iomsg=errormsg) base(null())

    if (stat == 0) ERROR STOP(1_4)

end


subroutine unformattedWrite (dtv, unit, iostat, iomsg)
use m
    class (base), intent(in) :: dtv
    integer, intent(in) :: unit
    integer, intent(out) :: iostat
    character(*), intent(inout) :: iomsg

    write (unit+1, iostat=iostat, iomsg=iomsg) ISNULL
end subroutine

The test case is expecting a runtime iostat= to be set because the child data transfer procedure uses a different UNIT number.
Flang seems ignore it.
Is this an intended extension?

Metadata

Metadata

Assignees

No one assigned

    Labels

    flang:runtimequestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions