g77 bug report

Theodore W. Hall twhall@cuhk.edu.hk
Tue Nov 12 01:06:00 GMT 2002


First, THANK YOU for making g77 available on Mac OS X!



SYSTEM
------

% uname -a
Darwin ted.arch.cuhk.edu.hk 6.1 Darwin Kernel Version 6.1: Fri Sep  6 23:24:34 PDT 2002; root:xnu/xnu-344.2.obj~2/RELEASE_PPC  Power Macintosh powerpc

% g77 -v
Reading specs from /usr/local/lib/gcc-lib/powerpc-apple-darwin5.4/3.1/specs
Configured with: ../gcc3/configure --enable-pfe --disable-nls --enable-languages=c,f77
Thread model: single
Apple Computer, Inc. GCC version 1110, based on gcc version 3.1 20020420 (prerelease)



BUG
---

In a series of SEQUENTIAL UNFORMATTED writes to an external file, each
subsequent WRITE over-writes the previous.  This is not a problem for
FORMATTED writes; only UNFORMATTED.



TEST PROGRAM
------------

% cat testwrite.f
       PRINT *, 'Writing sequential unformatted data ...'
       OPEN  (UNIT   = 1,
      &       FILE   = 'bin.dat',
      &       STATUS = 'UNKNOWN',
      &       ACCESS = 'SEQUENTIAL',
      &       FORM   = 'UNFORMATTED',
      &       ERR    = 91)
       WRITE (UNIT   = 1, ERR    = 92) 1, 2, 3
       WRITE (UNIT   = 1, ERR    = 92) 4, 5
       WRITE (UNIT   = 1, ERR    = 92) 6
       CLOSE (UNIT   = 1,
      &       STATUS = 'KEEP',
      &       ERR    = 93)
       PRINT *, 'Writing sequential formatted data ...'
       OPEN  (UNIT   = 1,
      &       FILE   = 'txt.dat',
      &       STATUS = 'UNKNOWN',
      &       ACCESS = 'SEQUENTIAL',
      &       FORM   = 'FORMATTED',
      &       ERR    = 91)
       WRITE (UNIT   = 1, FMT    = 1, ERR    = 92) 1, 2, 3
       WRITE (UNIT   = 1, FMT    = 1, ERR    = 92) 4, 5
       WRITE (UNIT   = 1, FMT    = 1, ERR    = 92) 6
       CLOSE (UNIT   = 1,
      &       STATUS = 'KEEP',
      &       ERR    = 93)
     1 FORMAT (3I4)
       PRINT *, 'Done.'
       STOP
    91 PRINT *, 'OPEN error.'
       STOP
    92 PRINT *, 'WRITE error.'
       STOP
    93 PRINT *, 'CLOSE error.'
       STOP
       END

% g77 -W -Wall -O -o testwrite testwrite.f
%

% ./testwrite
  Writing sequential unformatted data ...
  Writing sequential formatted data ...
  Done.
%

% cat txt.dat
    1   2   3
    4   5
    6

% hexdump -C bin.dat
00000000  00 00 00 04 00 00 00 06  00 00 00 04 00 00 00 08  |................|
00000010  00 00 00 0c                                       |....|
00000014
%



EXPECTED RESULT
---------------

% hexdump -C bin.dat
00000000  00 00 00 0c 00 00 00 01  00 00 00 02 00 00 00 03  |................|
00000010  00 00 00 0c 00 00 00 08  00 00 00 04 00 00 00 05  |................|
00000020  00 00 00 08 00 00 00 04  00 00 00 06 00 00 00 04  |................|
%

That is,

    record length   00 00 00 0c
    data            00 00 00 01   00 00 00 02   00 00 00 03
    record length   00 00 00 0c

    record length   00 00 00 08
    data            00 00 00 04   00 00 00 05
    record length   00 00 00 08

    record length   00 00 00 04
    data            00 00 00 06
    record length   00 00 00 04

Note that in the actual output, following the last record

    00 00 00 04   00 00 00 06   00 00 00 04

are the trailing record lengths of the two previous records

    00 00 00 08   00 00 00 0c

which seems to indicate that the earlier longer records were over-written
by the later shorter ones.

Thanks for any help.  Best regards.

    ---   Ted Hall

--------------------------------------------------------------------------
Dr. Theodore W. Hall                   voice: +852-2609-6551
Department of Architecture             fax:   +852-2603-5267
Chinese University of Hong Kong        mailto:twhall@cuhk.edu.hk
Sha Tin, Hong Kong, China              http://www0.arch.cuhk.edu.hk/~hall/



More information about the Gcc-bugs mailing list