DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT

Geert Bosch bosch@gnat.com
Thu Apr 17 22:07:00 GMT 2003


On Thursday, Apr 17, 2003, at 16:15 America/New_York, Alexandre Oliva 
wrote:
> Ok, you got me curious.  Would you mind explaining to an Ada-clueless
> person how come these two cases can possibly be different?  In my
> C-centric view, I really can't see the difference.  Code snippets
> demonstrating the semantic difference would be highly appreciated.
>

Below is an example which is required not to raise Program_Error:

with System.Storage_Elements; use System.Storage_Elements;
procedure T is

    type Point is record
       X, Y, Z : Long_Float;
    end record;

    type Path is array (Positive range <>) of Point;
    pragma Pack (Path);

    Q : Point;
    for Q'Alignment use 16;

begin
    if Q'Address mod 16 /= 0 then
       raise Program_Error;
    end if;
end T;


> Waiting to be enlightened, :-)

Hope the example helps. Yell if not :-)



More information about the Gcc-patches mailing list