Newsgroups: comp.os.msdos.djgpp From: hoogenrd AT natlab DOT research DOT philips DOT com (Hoogenraad, dr. J.H.) Subject: Re: f2c+djgpp Sender: news AT natlab DOT research DOT philips DOT com (USEnet Subsystem) Message-ID: Date: Tue, 14 Jan 1997 15:03:52 GMT Lines: 44 References: <9701121422 DOT AA18628 AT cambridge DOT scr DOT slb DOT com> Organization: Philips Research To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp In article <9701121422 DOT AA18628 AT cambridge DOT scr DOT slb DOT com> combee AT cambridge DOT scr DOT slb DOT com (Leendert Combee) writes: >From: combee AT cambridge DOT scr DOT slb DOT com (Leendert Combee) >Subject: f2c+djgpp >Date: Sun, 12 Jan 1997 14:22:15 GMT > For those who - like me - use f2c + djgpp to compile fortran sources, I > have noticed a curious but very serious bug in the output of f2c! Maybe > someone can confirm this (since I just copied djgpp-pre-compiled binaries > of f2c (f2c280896) - I have no idea to whom I should report this): > Fortran example: > subroutine test(a,n) > integer n,i > real a(n) > do i = 1, n > a(i) = .... > end do > return > end > This gets translated into a few lines of c-code, the crucial bit being: > > /* Parameter adjustments */ > --a; > (the reason being that a[1] is now really the first element (index 0) of the > original array). THE PROBLEM IS THAT POINTER a IS **NEVER** RESET: ++a > So that if test is called twice, the pointer a is decreased *again*. > I could not believe this when inspecting code, but I got suspicious when > f2c+djgpp compiled code gave different results than f77 on unix. > Anyone any comments?? Anyone with a more recent f2c willing to check his/her > code or the above simple example? > To me, it seems this is exactly what you want: on the next call of text, the ORIGINAL pointer is passed again to the function, and is should be decreased again. If your theory were right, calling test twice would yield different results for both calls. Just try that ! Jan Hoogenraad