NOT Educating FORTRAN programmers to use C
Jim Giles
jlg at lambda.UUCP
Wed Jan 17 11:45:47 AEST 1990
>From article <651 at chem.ucsd.EDU>, by tps at chem.ucsd.edu (Tom Stockfisch):
> subroutine sub( a, m )
> double precision a(m)
> ...
> end
> program
> real r(5)
> double precision d1(2), d2(2)
> equivalence ( d1(1), r(1) ), ( d2(1), r(2) )
> C d1() and d2() can't both be aligned on an 8 byte boundary
> call sub( d1, 2 )
> call sub( d2, 2 )
> end
As I said before, whichever double was odd-aligned would receive a
warning message. Most users regard such a problem as a mistake on
their part. The only implementation I've seen where there was any
debate on this issue was one where the subroutine was always compiled
to generate the slow references. By popular demand from the users,
this implementation was changed to always use the fast references
for double. This required the implementor to issue a fatal for the
subroutine call which was mis-aligned. I don't know anyone who
complained about this (in spite of the fact that it was, strictly
speaking, non-standard).
By the way, both Fortran and C exhibit this same problem for character
data types. Neither language requires characters to be word aligned,
and so, on word addressed machines, the compiler must generate lond
sequences of code to fetch/store character arguments. Contrary to the
above experience, I suspect _most_ users would complain if characters
had to be word aligned. Further, I suspect they would also complain
if forced to use you 'unaligned' attribute in their declarations.
J. Giles
More information about the Comp.lang.c
mailing list