g77 RTL possible error - egcs 1.1.1

craig@jcb-sc.com craig@jcb-sc.com
Mon Jan 25 13:23:00 GMT 1999


>I have noticed an inconsistency between egcs 1.1.1 g77 on Linux and two
>commercial f77 compilers (Solaris and Digital Unix) when trying to
>accidently OPEN a file which is a directory:-
>
>      open(unit=1, name='News', status='old')
>
>With g77 this works BUT any attempt to read from unit 1 fails with EOF.
>A Linux "strace" on the process shows the C "read" returns EISDIR
>
>Both commercial compilers fault the OPEN statement with errors such as
>
>open: [21] Is a directory
>logical unit 1, named 'News'
>Abort (core dumped)
>
>or will set IOSTAT if present.
>
>The g77 behaviour seems to be a hangover from libf2c and is, I feel,
>incorrect.

I think "incorrect" is overly strong, since I doubt any relevant standard
weighs in on this (maybe POSIX does, though -- I don't have copies of
any POSIX standards AFAIK).

But "not ideal" might apply.

What I'm not sure about is whether some vendors might consider it a
*feature*, in that it allows using OPEN on a directory followed by
some kind of facility to actually read the directory.  (I don't know
of any such facility in libf2c, though in classic/ancient UNIX, straight
binary reads of the directory worked, I believe.)

Perhaps you should contact David Gay (the maintainer of libf2c) and
discuss this issue with him.  g77 will probably just follow suit
with whatever he does in this area -- libg2c is already too different
from libf2c in many ways to strike out in a different direction on this.

        tq vm, (burley)



More information about the Gcc-bugs mailing list