Am 21.10.19 um 21:42 schrieb J. Gareth Moreton:
On 21/10/2019 20:00, Florian Klämpfl wrote:
What's the problem with

{$push}
{$codealign RECORDMIN=16}
type complex = record
                      re : real;
                      im : real;
end;
{$pop}

?

Hi Florian,

I tried that, but that puts each individual field on a 16-byte boundary

Then do:

{$push}
{$codealign RECORDMIN=16}
type dummyrec = record
        b : byte;
end;

{$pop}
type complex = record
       case byte of
          1 : (
                      re : real;
                      im : real
              );
          2 : (alignmentdummy : dummyrec);
end;

I thought I mentioned this trick even somewhere :)

parameters passed into the function may not be aligned (e.g. when deferencing a pointer on the heap after calling, say, "New(complex);"), hence why the compiler can only go by the 8-byte aggregate alignment.

No. Data is guaranteed to be aligned at it's natural boundary when it is passed without further information.
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to