From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,4dd5c7301163bec5 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!w3g2000hsg.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Misaligned address error Date: Fri, 07 Sep 2007 14:41:27 -0700 Organization: http://groups.google.com Message-ID: <1189201287.806186.103630@w3g2000hsg.googlegroups.com> References: <1189199157.591747.278390@r34g2000hsd.googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Trace: posting.google.com 1189201287 23063 127.0.0.1 (7 Sep 2007 21:41:27 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 7 Sep 2007 21:41:27 +0000 (UTC) In-Reply-To: <1189199157.591747.278390@r34g2000hsd.googlegroups.com> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.7.12-1.3.1,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: w3g2000hsg.googlegroups.com; posting-host=66.126.103.122; posting-account=ps2QrAMAAAA6_jCuRt2JEIpn5Otqf_w0 Xref: g2news2.google.com comp.lang.ada:1805 Date: 2007-09-07T14:41:27-07:00 List-Id: On Sep 7, 2:05 pm, shaunpatter...@gmail.com wrote: > i'm working with some really old legacy code that seemed to be working > fine with gnat pro 3.16a1. However, we decided to upgrade to gnat > 5. > > Everything built fine - however, I'm getting a misaligned address > value error at runtime: > > raised PROGRAM_ERROR : data_reader.2.ada:109 misaligned address > value > > The code: > > subtype Data_Type is Character; > > type Data_Type_Array is array (Natural range <>) of Data_Type; > > Data_String : Data_Type_Array (1 .. 8) := (others => Data_Type > (Ascii.Nul)); > for Data_String'Alignment use 4; > for Data_String'Size use 8 * Data_Type'Size; > -- global data buffer for reading and writing to file > > -- quick conversion variables > One_Byte_Number : One_Byte_Number_Type; > for One_Byte_Number'Address use Data_String'Address; > > Two_Byte_Number : Two_Byte_Number_Type; > for Two_Byte_Number'Address use Data_String'Address; > > Four_Byte_Number : Four_Byte_Number_Type; > for Four_Byte_Number'Address use Data_String'Address; > > Four_Byte_Signed_Number : Four_Byte_Signed_Number_Type; > for Four_Byte_Signed_Number'Address use Data_String'Address; > > Four_Byte_Float : Float_Type; > for Four_Byte_Float'Address use Data_String'Address; > > Eight_Byte_Float : Long_Float_Type; > for Eight_Byte_Float'Address use Data_String'Address; --- FAILS ON > THIS LINE --- > > Could anyone help me make sense of this exception? I don't know what a Long_Float_Type is. What is it, and more importantly, what is Long_Float_Type'Alignment? Since Data_String'Alignment is 4, Data_String can be located on any address that is a multiple of 4 bytes (I assume you're compiling for a byte- addressable machine); if it got located on an address that is a multiple of 4 but not a multiple of 8, and if Long_Float_Type'Alignment is 8, then the address clause can't be honored properly. (RM 13.3(27) says program execution is erroneous in this case; GNAT has decided to make this raise a Program_Error at runtime.) If Long_Float_Type'Alignment is indeed 8, then you should change Data_String'Alignment to 8 also, to make sure that Data_String will be on an 8-byte boundary. (P.S. I don't know GNAT well enough to know whether that will succeed; not all Alignment clauses have to be supported.) (Apologies if this is a duplicate post. Google is acting up, yet again.) Hope this helps, -- Adam