Mark Kettenis wrote: > From: Dale Johannesen <[EMAIL PROTECTED]> > Date: Thu, 21 Jul 2005 16:56:01 -0700 > > On x86 currently the alignments of double and long long are linked: > they are either 4 or 8 depending on whether -malign-double is set. > This follows the documentation of -malign-double. But it's wrong for > what we want the Darwin ABI to be: the default should be that double > is 4 bytes and long long is 8 bytes. > > I have a strong suspicion there is a reason why the two are linked, > and that that reason is FORTRAN. A lot of FORTRAN code assumes > EQUIVALENCE of floating-point and integer types of equal size. Such > code will in all likelyhood break if those types have different > alignment. For x86 this means that int/float and long long/double > will have to have the same alignment.
This might indeed be a problem, as the alignments not only have to be the same if they appear in an equivalence, but also in arrays or when using the TRANSFER intrinsic. Out of the types dicussed, the standard only specifies this for default INTEGERs (=int in C) and default REALs (=float in C), but users do expect this to consistently extend to bigger types, otherwise they consider the compiler buggy instead of their code. More precisely, the standard says this: a scalar variable of a certain type occupies a certain number of "storage units". Default INTEGERs, and REALs take one storage unit, default COMPLEX and DOUBlE PRECISION (= REAL*8 = double in C) take two storage units. Finally, arrays of these types take a sequence of contiguous storage units. Details can be found in section 14.6.3 of the Fortran 95 standard. These sequences of storage units can be equivalenced (i.e. a certain overlap between the sequences is requested by the user. This is only allowed for variables of the same type, but the extension to different types is common and widely used). Furthermore the TRANSFER intrinsic can be used to copy the binary representation of variable/array A into variable/array B; it is therefore also sensitive to memory layout. - Tobi