This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: G77 bug ? or is this by design ?


Yuen Keong Ng wrote:

> I am using the g77 fortran compiler and for a recent
> project I have to read/access binary output files,
> which are produced by another project.
> 
> An easy way of coding it appeared to buffer the I/O
> through a character string by an inline read statement,
> i.e.   READ(string,'(A4)') value
> 
> This works fine for almost all values, except those
> where a '0A'X value in one of the bytes of value
> is encountered. In that case the byte(character)
> returned is an ASCII SPC ('20'X).
> 
> Is this a bug ? Or is this actual by design?

Well, 1) it's not a bug, because the "A" format designator may only be
used in combination with a character entity (unfortunately, g77 doesn't
warn for this, because the general case is extremely complicated, much
more so than the seemingly equivalent scanf format string test), 2) it's
not doing this by design either - it's simply a consequence of the way
the run time routine in libf2c/libI77 (which is written in C) reads the
string (which will later be stored into "value").

There is no general solution to the problem you face in any existing
Fortran Standard; Fortran 200x will contain a description of Stream I/O,
which is basically the way you'd read such a file in C.

-- 
Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290
Saturnushof 14, 3738 XG  Maartensdijk, The Netherlands
GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
GNU Fortran 95: http://g95.sourceforge.net/ (under construction)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]