Closed ohno-fj closed 1 month ago
@llvm/issue-subscribers-flang-runtime
Author: None (ohno-fj)
The FINAL subroutine in that program should never be called. Since the FINAL subroutine is the only place in the code that writes to unit 2, unit 2 is never written, and the READ statement later correctly fails.
(GNU Fortran does finalize the local variable ty0_var
in subroutine sub
, but that variable has the SAVE attribute and so the finalization is incorrect.)
Execution error occurs because
subroutine
specified infinal-subroutine-name-list
ofFINAL
statement is not executed correctly.Write
statement in thesubroutine
creates a file namedfile.2
with no data.Then the empty file is read, resulting in a runtime error.
The following are the test program, Flang-new, Gfortran and ifort compilation/execution result.
sngg632d_.f90: