www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/01/12/09:49:25

From: combee AT cambridge DOT scr DOT slb DOT com (Leendert Combee)
Message-Id: <9701121422.AA18628@cambridge.scr.slb.com>
Subject: f2c+djgpp
To: djgpp AT delorie DOT com
Date: Sun, 12 Jan 1997 14:22:15 +0000 (GMT)
Mime-Version: 1.0

  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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019