Mail Archives: djgpp/1997/01/12/09:49:25
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?
Leendert Combee
- Raw text -