Coding standards (was Re: bug in L-BFGS-B? (PR#8099))
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