This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch, Fortran] PR60286 - fix INQUIRE for write= with stdout/stdin/stderr
- From: Tobias Burnus <burnus at net-b dot de>
- To: Janus Weil <janus at gcc dot gnu dot org>, Tobias Burnus <tobias dot burnus at physik dot fu-berlin dot de>
- Cc: gcc-patches <gcc-patches at gcc dot gnu dot org>, gfortran <fortran at gcc dot gnu dot org>
- Date: Fri, 21 Feb 2014 08:36:58 +0100
- Subject: Re: [Patch, Fortran] PR60286 - fix INQUIRE for write= with stdout/stdin/stderr
- Authentication-results: sourceware.org; auth=none
- References: <20140220125457 dot GA22026 at physik dot fu-berlin dot de> <CAKwh3qjVybjf6ZSYrYEtHu0TQEER5QKT3Kz5gNDRxVgBk-Pknw at mail dot gmail dot com> <20140220183540 dot GA4109 at physik dot fu-berlin dot de> <CAKwh3qi_0iRxkiNnOsjN_Ybr+UmbONRpP5w4VV3d+=zJPg0R6Q at mail dot gmail dot com>
Hi,
Janus Weil wrote:
Namely, either unconditionally using for UNIT=:
if ((cf & IOPARM_INQUIRE_HAS_READWRITE) != 0)
p = (u->flags.action == ACTION_READWRITE) ? yes : no;
We probably still need some special case for stdin/stdout/stderr.
Do we? If the new version of the patch works correctly, then it seems
that we don't?
I wrote that before carefully checking the code and actually doing the
modification. unit.c's init_units sets them correctly.
* Advantage of access(): Gives the true file mode by the OS.
* Advantage of the open mode: Gives the permissions for which the
unit was opened.
Is there actually a difference?
Well, you can do:
open(99, file="test.dat", action="write")
write(99, *) 6
rewind(99)
read(99, *) i
end
If you look at the file permissions of the generated file, they are -
here- '-rw-r--r--', i.e. for the user readable and writable.
However, the code will fail due to the action='write' at run time with:
Fortran runtime error: Cannot read from file opened for WRITE
That's another reason for using the action mode with by-unit inquire.
In any case I think INQUIRE with FILE should use the former, while
INQUIRE with UNIT should use the latter, which is apparently what your
new patch does.
I concur - hence, I implemented it that way.
I like the new version much better, because it is more general and
even simpler. To my taste it is ok for trunk ...
Committed as Rev. 207979.
Thanks for the review!
Tobias