From p.dalgaard at biostat.ku.dk  Sun Aug 28 14:10:57 2005
From: p.dalgaard at biostat.ku.dk (Peter Dalgaard)
Date: 28 Aug 2005 14:10:57 +0200
Subject: [Rd] Coding standards (was Re:  bug in L-BFGS-B? (PR#8099))
In-Reply-To: <17169.42000.451244.55081@bossiaea.maths.uwa.edu.au>
References: <20050827141028.DCE0218B9F@slim.kubism.ku.dk>
	<Pine.LNX.4.61.0508271525290.4656@gannet.stats>
	<17169.42000.451244.55081@bossiaea.maths.uwa.edu.au>
Message-ID: <x2r7cetg6m.fsf@turmalin.kubism.ku.dk>

Berwin A Turlach <berwin at maths.uwa.edu.au> writes:

> The problem is, that the code produced by f2c is decrementing pointers
> to simulate 1-based vectors and the C FAQ is pretty unambigious about
> the fact that this provokes undefined behaviour, see
>         http://www.eskimo.com/~scs/C-faq/q6.17.html
> 
> As far as I understand, this translated code mostly stems from the
> time when some platforms did not have ready access to a fortran
> compiler and, hence, f2c was used (extensively?).  But now, with g77
> this does not seem to be an issue anymore.  So I wonder whether there
> are any plans of returning to the original fortran code?  Or are there
> plans to clean up these f2c'd code snippet to make them ANSI C
> compliant?  

There's more to it than that. F2c has also been used in places to make
Fortran code reentrant, which it is generally not. I forget whether we
were ever bitten by nested calls to optim(), but we certainly was by
integrate().

There is of course no argument against the fact that the
pointer-decrement trick goes against the C specs, but I do wonder
whether it is *actually* biting anyone these days. The remarks in the
C FAQ seem to mainly refer to segmented architectures like the
original IBM PC. With modern flat address spaces, it would seem quite
unlikely to run into trouble. 

-- 
   O__  ---- Peter Dalgaard             ?ster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: (+45) 35327907



[Rd] Coding standards (was Re: bug in L-BFGS-B? (PR#8099))
Peter Dalgaard