public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libfortran/41387]  New: OPEN, STATUS='NEW' of a symbolic link to a non-existing file fails.
@ 2009-09-17  9:09 toon at moene dot org
  2009-09-17 13:26 ` [Bug libfortran/41387] " toon at moene dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: toon at moene dot org @ 2009-09-17  9:09 UTC (permalink / raw)
  To: gcc-bugs

The following program:

      OPEN(UNIT=1,FILE='noot',STATUS='NEW')
      END

when compiled/linked into a.out and run as follows:

$ rm aap
$ ln -s aap noot
$ ./a.out

gives:

At line 1 of file a.f (unit = 1, file = '')
Fortran runtime error: File 'noot' already exists

Other compilers (tested: xlf (IBM) and ifort (Intel)) permit to open a
non-existing file as 'NEW' this way.

The reason our run-time library doesn't is that in io/unix.c, we open a 'NEW'
file with open(...., O_CREAT | O_EXCL, ...).

The man page of open says about O_EXCL:

       O_EXCL

Ensure  that  this  call creates the file: if this flag is specified in
conjunction with O_CREAT, and pathname already exists, then open() will fail.
The behavior of O_EXCL is undefined if O_CREAT is not specified.

When these two flags are specified, symbolic links are not followed: if
pathname is a symbolic link, then open() fails regardless of where the
symbolic link points to.


-- 
           Summary: OPEN, STATUS='NEW' of a symbolic link to a non-existing
                    file fails.
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libfortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: toon at moene dot org


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


^ permalink raw reply	[flat|nested] 8+ messages in thread
[parent not found: <bug-41387-4@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2015-09-06 10:59 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-17  9:09 [Bug libfortran/41387] New: OPEN, STATUS='NEW' of a symbolic link to a non-existing file fails toon at moene dot org
2009-09-17 13:26 ` [Bug libfortran/41387] " toon at moene dot org
2009-09-17 14:59 ` kargl at gcc dot gnu dot org
2009-09-17 19:16 ` jvdelisle at gcc dot gnu dot org
2009-09-17 19:57 ` toon at moene dot org
2009-09-18  3:52 ` kargl at gcc dot gnu dot org
2009-09-20 17:03 ` toon at moene dot org
     [not found] <bug-41387-4@http.gcc.gnu.org/bugzilla/>
2015-09-06 10:59 ` LpSolit at netscape dot net

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).