This is the mail archive of the gcc-patches@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]

Recursive I/O bug when combining formatted direct and sequential I/O


I wrote on fortran@gnu.org:

>  I simplified a posted example to comp.lang.fortran thusly:
>
>        OPEN(11,FILE='testf.out',FORM='FORMATTED',
>      +   RECL=8,ACCESS='DIRECT')
>        Write(11,'(i8)',rec=1,iostat=itest) 10
>        write(6,*)'Written',10,itest END
>
>  Compiled with a very recent egcs snapshot from the 1.1
>  release branch, I get:
>
>  I/O recursion: I/O started while already doing I/O
>  apparent state: unit 11 named testf.out last format: (i8)
>  lately writing direct formatted external IO IOT trap
>
>  Probably a flag being left set after direct formatted
>  I/O ...

This problem is solved with the following patch, in which I copied  
the f__init flag (meant to track recursive I/O) treatment from due.c  
(direct *un*formatted I/O) to [ds]fe.c (direct *formatted* I/O):

*** dfe.c.old   Fri Sep  4 13:54:28 1998
--- dfe.c       Fri Sep  4 14:02:00 1998
*************** c_dfe(cilist *a)
*** 67,70 ****
--- 67,72 ----
  #endif
  {
+       if(f__init != 1) f_init();
+       f__init = 3;
        f__sequential=0;
        f__formatted=f__external=1;
*************** integer s_rdfe(cilist *a)
*** 93,98 ****
  {
        int n;
-       if(f__init != 1) f_init();
-       f__init = 3;
        f__reading=1;
        if(n=c_dfe(a))return(n);
--- 95,98 ----
*************** integer s_wdfe(cilist *a)
*** 116,121 ****
  {
        int n;
-       if(f__init != 1) f_init();
-       f__init = 3;
        f__reading=0;
        if(n=c_dfe(a)) return(n);
--- 116,119 ----
*** sfe.c.old   Fri Sep  4 14:01:05 1998
--- sfe.c       Fri Sep  4 14:01:21 1998
*************** integer e_wsfe(Void)
*** 36,39 ****
--- 36,40 ----
  integer e_wdfe(Void)
  {
+       f__init = 1;
        return en_fio();
  }


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