http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48960

           Summary: OPEN statement modifies NEWUNIT variable on error
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libfortran
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: thenl...@users.sourceforge.net


If the NEWUNIT= specifier in the OPEN statement is used, the variable is
modified if an error occurs during the execution of the OPEN statement.

This does not conform to Fortran 2008 which demands:

9.5.6.12 NEWUNIT= specifier in the OPEN statement

1 The variable is defined with a processor determined NEWUNIT value if no error
occurs during the execution of the OPEN statement. If an error occurs, the
processor shall not change the value of the variable.

Example:

program test_newunit
    integer :: st, un = 0
    open (newunit=un, file='nonexisting.dat', status='old', iostat=st)
    if (un /= 0) call abort
end program test_newunit

Result: If the file 'nonexisting.dat' does not exist, the program aborts.

Expected result: If the file 'nonexisting.dat' does not exist, the program
should not abort.

Reply via email to