[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference turris::ada

Title:DEC Ada
Notice:Ada is no longer a trademark of the US Government
Moderator:KMOOSE::CMCCUTCHEON
Created:Mon Jan 27 1986
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:3874
Total number of notes:16668

3853.0. "%ADAC-E-BAD_ALIGNMENT with code which compiled on VAX" by CSC32::D_SANFORD () Tue Mar 25 1997 13:56

    Ada V3.3, OpenVMS Alpha V6.2

    I have a customer porting VAX code to Alpha and they receive a 
    compilation error:

      %ADAC-E-BAD_ALIGNMENT, (1) Must be aligned on at least a 32 bit boundary

    He has 7 bytes followed by STARLET.DATE_TIME_TYPE and gets the above
    message.  He uses "pragma Component_Alignment (Storage_Unit, record);"
    and that corrected most of the problems, but not this date.  He said
    they use "for use" or some "use" clause.  

    Not familiar enough with Ada to help the customer.  This is an example 
    of what I though it might be, but it does not fail and always aligns
    on a 32 bit boudary.  I was trying to prevent from having him send
    us a short example.

    Regards, Drew Sanford
    Customer Support Center
    C970306-4311



    with Starlet;
    with System;
    with Text_Io;

    procedure P is

        type A is array (1..7) of System.unsigned_byte;

        type B is
            record
                X : A;
                Y : Starlet.Date_time_Type;
            end record;

--        pragma Pack (A);
        pragma Component_Alignment (Storage_Unit, A);
        pragma Component_Alignment (Storage_Unit, B);

        V : B;

    begin
        Text_Io.Put_Line ("Y offset =" & Integer'Image
            (System.To_Integer (V.Y'Address) - System.To_Integer (V'Address)));
    end P;
T.RTitleUserPersonal
Name
DateLines
3853.1I can't get it to failFLOYD::YODERMFYTue Mar 25 1997 15:494
Is this related to note 3816?

I tried some "obvious" possibilities based on the code in .0 but couldn't
produce the error.  I'm afraid we may need to ask for a reproducer.  :-)
3853.2Check if user has record representation clauseKMOOSE::CMCCUTCHEONCharlie McCutcheonWed Mar 26 1997 12:0214
I was only able to get this to "fail" if I added a record representation
clause which tells Ada exactly where to put each record component:

        for B use
            record
                X at 0 range 0..55;
                Y at 7 range 0..64;
            end record;

Then, the "Must be aligned on at least a 32 bit boundary" is valid, because
the user has asked us specifically for it to be put at a non-alligned
boundary.

Charlie
3853.3Would code compiled on VAX fail on Alpha?CSC32::D_SANFORDWed Mar 26 1997 18:4311
    Re: .1 simular, but a different customer.  This is porting VAX to
    Alpha, not user a third party compiler.
    
    Re: .2 that is what the customer is doing, but he claims this work
    with the VAX Ada compiler...  
    
    Is it possible that a DATE_TIME_TYPE would be allowed on a 8 bit
    boundary on VAX, but must be on 32 bit on the Alpha?  Maybe they
    are not using DEC Ada and just don't want me to know.
    
    -drew  
3853.4CSC32::D_SANFORDWed Mar 26 1997 19:1414
    Customer solved his problem.  He was using STARLET.DATE_TIME_TYPE
    and since this was defined as a LONGWORD array I sugggested using 
    a byte definition, so the customer found:
    
    	CALENDAR.TIME_AS_BYTES
    
    He uses this and it works...  So either VAX allowed byte/word
    alignment or STARLET.DATE_TIME_TYPE was defined differently.
    
    Not sure if this will cause an application failure, but they are
    only porting the code, they did not write it, so they need to be
    careful in making any changes.
    
    -drew
3853.5CALENDAR.TIME is more portable solutionKMOOSE::CMCCUTCHEONCharlie McCutcheonThu Mar 27 1997 12:197
>    	CALENDAR.TIME_AS_BYTES

If you want to be portable, able to compile on VAX or Alpha, try
CALENDAR.TIME instead.  I don't see TIME_AS_BYTES in the VAX version
of package Calendar.

Charlie