[PATCH, fortran testsuite] read_eof.f90 open file bug

Paul Brook paul@codesourcery.com
Fri Dec 31 18:29:00 GMT 2004


On Thursday 30 December 2004 21:50, Thomas Koenig wrote:
> Paul Brook wrote:
> > On Thursday 30 December 2004 12:22, Thomas Koenig wrote:
> > > Stupid question: Why should opening /dev/null twice fail?
> >
> > Section 9.3.2:
> > "A unit shall not be connected to more than one file at the same time,
> > and a file shall not be connected to more than one unit at the same time"
> >
> > You could argue that /dev/null is a special case, and we should allow
> > opening it multiple times as an extension.
>
> Does this mean that the Unix colloquialism
>
> someprog > logfile 2>&1
>
> is not supposed to work with gfortran once unit 0 gets preconnected
> to stderr?

If we also preconnected stderr to a fortran unit then yes, that would be 
technically illegal. It's worth noting that preconnection of units is already 
outsite the remit of the F95 standard.
I expect that writing to both stderr and stdout is liable to give 
unpredictable results when both are connected to the same file.

One solution might be to treat std{in,out,err} as files in their own right, 
rather than looking to see what they're actually connected to. It's then up 
to the user to make sure they don't overlap.

Paul



More information about the Fortran mailing list