Bug 18653 - open call should open for read-only if open for read/write fails.
Summary: open call should open for read-only if open for read/write fails.
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libfortran (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.0.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
: 18297 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-11-24 17:46 UTC by Steve Ellcey
Modified: 2004-12-08 16:54 UTC (History)
2 users (show)

See Also:
Host: ia64-hp-hpux11.23
Target: ia64-hp-hpux11.23
Build: ia64-hp-hpux11.23
Known to work:
Known to fail:
Last reconfirmed: 2004-11-24 18:03:45


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Steve Ellcey 2004-11-24 17:46:09 UTC
If we have the following program:

      OPEN(10,FILE='wup.in',STATUS='OLD')
      CLOSE(10, STATUS='KEEP')
      END

And a data file that is readable by everyone and writable by nobody:

$ ll wup.in
-r--r--r--   1 sje        other             0 Nov 24 08:43 wup.in

gfortran will fail on the open (because it tries to open for read & write),
other compilers will open for read-only if they cannot open for reading and
writing.

Opening for read-only is not required by the Fortran standard but it is how
most Fortran compilers (HP, Intel, g77) behave.
Comment 1 Andrew Pinski 2004-11-24 18:03:45 UTC
Confirmed, I will reopen the other bug and close it as a dup of this one.
Comment 2 Andrew Pinski 2004-11-24 18:18:05 UTC
*** Bug 18297 has been marked as a duplicate of this bug. ***
Comment 3 Steve Ellcey 2004-12-08 16:52:53 UTC
This has been fixed with the patch
http://gcc.gnu.org/ml/fortran/2004-12/msg00017.html
which is now checked in on ToT.
Comment 4 Andrew Pinski 2004-12-08 16:54:49 UTC
Fixed by:
2004-12-07  Steve Ellcey  <sje@cup.hp.com>

        * io/io.h (open_external): Change prototype.
        * io/unix.c (regular_file): Change prototype and set flags->action if
        needed.
        (open_external): Ditto.
        * io/open.c (new_unit): Let open_external set flags->action.