Variable-Length Array Parameters in NCEG C

uunet!phx.cam.ac.uk!NMM1 uunet!phx.cam.ac.uk!NMM1
Mon Jul 6 11:37:42 PDT 1992


> > But what happens in a case like
> >
> >  static int n=3;
> >  void a(float b[n], int n)
> >
> Having no Fortran analog, this doesn't arise in simple translations into C,
>
> Wouldn't the following constitute a Fortran analog:
>
>  SUBROUTINE a( b, n )
>  COMMON/com1/n
>  REAL b( n )
>
> My copies of the relevant references are packed up right now, but I believe
> that this is illegal Fortran.  On the other hand, it would be more C-like
> for the local reference to override the static one, regardless of order
> of declaration.

Sorry, but this is legal Fortran.  On the other hand, no portable numerical
code ever uses this feature because the number of compilers that get it
wrong is legion!  It also severely impacts optimisation (for higher-dimension
arrays).

Nick Maclaren
University of Cambridge Computing Service



More information about the Numeric-interest mailing list