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

From: Peter Dalgaard <>
Date: Sun 28 Aug 2005 - 12:10:57 GMT

Berwin A Turlach <> 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
> 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
~~~~~~~~~~ - (                  FAX: (+45) 35327907

______________________________________________ mailing list
Received on Sun Aug 28 22:14:26 2005

This archive was generated by hypermail 2.1.8 : Mon 24 Oct 2005 - 22:27:45 GMT