Skip to content

[flang][runtime][IO] OPEN statement core dumps at runtime with not-existent file #122150

@mjklemm

Description

@mjklemm

When compiling below reproducer and running it with the opened file not being there, the executable core dumps:

$  flang-new -o readtest ./readtest.f90       
$  ./readtest                                 

fatal Fortran runtime error(/path/path/path/readtest.f90:9): End of file during input
[1]    1099765 IOT instruction (core dumped)  ./readtest

The expected output would be:

 ERROR

Reproducer:

program readtest
    implicit none
    character(len=10) :: dir_app
    real(8) :: rdum, rispin
    integer :: idum

    open(unit=12, file='data1.dat', access='direct', form='unformatted',status='unknown', recl=128)

    read(12,rec=1,err=17421) rdum,rispin ; idum=nint(rdum)

    write (*,*) rdum, rispin
    return

    17421 write(*,*) "ERROR"
end program

Metadata

Metadata

Assignees

Labels

crashPrefer [crash-on-valid] or [crash-on-invalid]flang:runtime

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions