This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch,libgfortran] PR28335 flush() / write() statement on closed units

Brooks Moses wrote:
Michael Paton wrote:
I've just run across the effects of this in the 20060729 snapshot, where
previously working code got runtime errors. It seems that Jerry's patch
makes it an error to attempt to CLOSE a unit which has not been OPENED, or
"associated". My reading of the f77 standard and a late draft of the 2003
standard show this to be explicitly permitted. I couldn't easily access the
F90 or F95 standards.

You are correct. Fortran 95 standard, 9.3.5, third para: "Execution of a CLOSE statement specifying a unit that does not exist or has no file connected to it is permitted and affects no file."

It appears to me that the patch to io/close.c should simply be reverted to fix this. It may be useful to also add a comment referencing the above line of the standard, e.g.:

/* CLOSE on unconnected unit is legal and a no-op: F95 std., 9.3.5. */

As a user whose (possibly misguided) program stopped working, I'll also confess to some brief irritation at the error text, "Can't find specified UNIT in CLOSE". In essence, the runtime knows I want to do a CLOSE on a specific UNIT, and it
has a problem with that, but it won't tell me which UNIT. I'm afraid that looking at error.c didn't give me a clearer idea of how a more useful error message could have been given within the existing program structure.

I would agree that "Can't find specified UNIT" is pretty unclear, and could be improved even without putting the actual unit number in the message. Even though this is moot for CLOSE given the above, the error message for FLUSH should probably be improved.

Perhaps "Specified UNIT in FLUSH is not connected"?

- Brooks

Changed error message as Brooks suggested for FLUSH. Reverted the error on CLOSE. Added comments to reference the standard. Kicked myself.

Committed to 4.1 and 4.2 under obvious and simple rule.

Sorry folks,


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]