g77 bug?

Wei Dong wei@blueyonder.co.uk
Mon Jul 30 10:55:00 GMT 2001


Hi,

The file I/O of g77 behaves strangely on my computer. I have attached the
code extracted  from my program to high-light this problem. It can be
compiled by g77 without any argument.

What I want to do is to wind a text file to a certain point, then overwrite
the existing text with new one. The executable generated by g77 either
refuses to add the text to file or appends them to the end of file.

I got this problem on Solaris8 IA, and Cygwin on Windows ME, but NOT on
RedHat 6/7 Linux.

The g77 is a part of gcc-3.0 binary for Solaris8 built by sunfreeware.com,
and the versions of g77, ld, as and OS are:

 GNU Fortran 0.5.26 20010617 (experimental)
 GNU ld 2.11.2
 GNU assembler 2.11.2
 SunOS dell 5.8 Generic_108529-08 i86pc i386 i86pc

I have tried a slight older version g77(gcc 2.95), but the situation is
same.

I found calling fseek immediately before write can do the trick. Hope you
can give me a better working around.

Wei


================================
c
c Problem program
c
      CHARACTER text*80
      OPEN(47,file='./tmp',status='unknown',form='formatted')
   10 read(47,100,end=30)text
      if(text(1:6).ne.'APPEND') goto 10
c  30 call fseek(47,ftell(47),0)
   30 write(47,100)'APPEND TEXT WILL NOT WORK WITHOUT FSEEK !'
      close(47)
  100 format(a)
      end
================================





More information about the Gcc-bugs mailing list