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-alpha binary file BACKSPACE does not work


[ doesn't fail on my m68k-next-nextstep3 too ]

>      program test1
>      real*8 a,b
>      dimension a(100), b(100)
>      open(unit=21,file='test.21',form='unformatted')
>      do i=1,100
>        a(i)=i
>      end do
>      write(21) a
>      do i=1,100
>        a(i)=a(i)+i
>      end do
>      write(21) a
>      backspace 21
>      read(21) b
>      print *, b(1), b(10), b(50), b(90), b(100)
>      end

>  This program runs fine on intel-egcs--g77,but on an alpha

>  do_us: end of file apparent state: unit 21 named test.21
>  lately reading sequential unformatted external IO Aborted
>  (core dumped)

>  is the result. Is this a bug in the compiler, the f2c
>  lib or our humble code.

During "backspace", the following code is executed (see  
egcs-1.0.1/gcc/f/runtime/libI77):

f_back (a=0x12010fcc8) at backspace.c:36
36              if(b->url>0)
(gdb)
47              if(b->ufmt==0)
(gdb)
48              {       (void) fseek(b->ufd,-(long)sizeof(int),SEEK_CUR);
(gdb)
49                      (void) fread((char *)&n,sizeof(int),1,b->ufd);
(gdb)
50                      (void)  
fseek(b->ufd,-(long)n-2*sizeof(int),SEEK_CUR);
(gdb) p n
$19 = 0

Note that n == 0, and therefore the "seek back" isn't effective.   
Could someone with more experience on Linux/Alpha join in to tell us  
the exact argument signature of fseek, as I suspect that the cast  
to long (64-bits on Alpha) might be wrong ...

HTH,
Toon.


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