Bug (or mis-feature) in g77 sequential file format
Toon Moene
toon@moene.indiv.nluug.nl
Fri Sep 18 08:28:00 GMT 1998
> I have come accross a problem with the way g77 treats
> sequential binary files on the alpha. My version is:
> GNU F77 version egcs-2.91.57 19980901 (egcs-1.1 release)
> (alpha-dec-osf4.0) compiled by GNU C version egcs-2.91.57
> 19980901 (egcs-1.1 release). GNU Fortran Front End
> version 0.5.24-19980804
> It turns out that this version of g77 for the alpha uses
> 8 bytes for the record's header and trailer (which hold
> the record length), while the very same g77 version on
> my PC running FreeBSD uses 4 bytes. The standard DEC
> Fortran compiler also uses 4-byte headers and trailers.
> This means that I cannot share binary files.
Excellent summary of the "problem". We realised this ourselves in
February. Basically, the options are:
1. Change the Alpha (and other architectures where `long' means
64 bits) to use `int' (32 bit) sized integers to count the
number of bytes in a record.
This would mean an incompatibility with previous releases of
egcs on those architectures.
2. Change all architectures to use 64 bit record lengths - this
would mean to break backwards compatibility for *those*
architectures.
And then, it wouldn't help. Most workstations use 32 bit integers
for the lengths of records in unformatted sequential files, but the
majority (in number of architectures) is big-endian, whereas the
Intel and Alpha architectures are little-endian - so you couldn't
transfer unformatted files between them anyhow.
The real solution is to switch to a file format that's portable
(i.e. "formatted" files) or write conversion routines.
HTH,
Toon.
More information about the Gcc-bugs
mailing list