DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT

Robert Dewar dewar@gnat.com
Tue Apr 22 00:15:00 GMT 2003


> And the reason is as I said: you specify alignment for a type both for
> interface and efficiency reasons, but for an object only for the latter.

Not quite. consider

   type R is array (Natural range <>) of Character;
   for R'Alignment use 1;

   X : R (1 .. 100);
   pragma Import (C, X);

now for the above, the generated code can only assume an alignment of 1.

But we might want to do

  Y : R (1 .. 1000);
  for Y'Alignment use 8;
  pragma Export (C, Y);

in a case where the C code expects an alignment for the object of 8 for
correct operation.

So even for objects, specifying an alignment different from that for the
type may be appropriately needed for functional correctness.





More information about the Gcc mailing list