| Issue |
58091
|
| Summary |
[flang] Signal end of file rather than error if namelist is not found in file
|
| Labels |
flang:runtime
|
| Assignees |
|
| Reporter |
jpenix-quic
|
Example program below:
```
subroutine test
integer, parameter :: read_unit=10
integer :: a
namelist /my_namelist/ a
namelist /missing_namelist/ a
open(unit=read_unit, file="namelist.txt", form="FORMATTED", status="NEW")
write(unit=read_unit, nml=my_namelist, err=1)
close(unit=read_unit)
open(unit=read_unit, file="namelist.txt", form="FORMATTED", status="OLD")
read(unit=read_unit, nml=my_namelist, err=2, end=3)
print *, "Read of my_namelist succeeded, as expected!"
print *, "Trying to read non-present namelist..."
read(unit=read_unit, nml=missing_namelist, err=2, end=3)
return
1 print *, "Error while writing!"
return
2 print *, "Error while reading!"
return
3 print *, "End of file when reading!"
return
end
program p
call test
end
```
gfortran and ifort both print "End of file when reading!" (please see https://godbolt.org/z/eT8KTE89o) but flang prints "Error while reading!" for me.
Would it be ok to change the behavior in flang to match that of gfortran/ifort? From what I understand, I don't think there is a set requirement one way or another for this, but 521.wrf_r in SPEC2017 seems to rely on `end` being taken in this situation and it seems that this is what gfortran and ifort do (although I am not sure about other compilers' behavior here).
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs