g77 write bug?

toon@moene.indiv.nluug.nl toon@moene.indiv.nluug.nl
Fri Dec 31 20:54:00 GMT 1999


Scott wrote:

I believe I've found an incomplete implementation of the
FORTRAN write routine.

The code is writing (using write()) to an internal character
string that is too small to contain the output using a provided
arbitrary (but correctly constructed) format field.  The code
incrementally increases the target string length until it succeeds.
I expect an error to be generated while the string is still
too short to hold the output string and to goto the specified
error label.  Instead, no error is generated causing
the subroutine to incorrectly identify the format field width.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

I'm afraid you're relying on behaviour of compilers that's not
sufficiently tied down in the Standard (I'm refering to the 
Fortran 77 Standard here, pertinent to g77).

_12.6 Error and End-of-File Conditions

_The set of input/output error conditions is processor dependent.

So that:


_12.9.5.2.1 Using a Format Specification.

...
 
On output, if the file is connected for direct access or is an internal file, the output list and format specification must not specify more characters for a record than can fit into the record.

means that it is illegal to specify a format that results in more
characters being written than the record length (in case of an 
internal file: the character variable length).

So while you're nicely being helped by the HP Fortran compiler,
what you do isn't necessarily possible with other compilers.

What exactly do you want to achieve ?  Perhaps there is another
(Standard) way to get at it ....

Hope this helps,
Toon Moene.



More information about the Gcc-bugs mailing list