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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,35af79fb6fbb1bb2,start X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!cyclone1.gnilink.net!gnilink.net!nx01.iad.newshosting.com!newshosting.com!news2.euro.net!news-out1.kabelfoon.nl!newsfeed.kabelfoon.nl!bandi.nntp.kabelfoon.nl!npeer.de.kpn-eurorings.net!npeer-ng1.kpn.DE!rz.uni-karlsruhe.de!feed.news.schlund.de!schlund.de!news.online.de!not-for-mail From: Michael Bode Newsgroups: comp.lang.ada Subject: Problem with representation clause in gnat 4.3 Date: Sat, 04 Oct 2008 00:08:54 +0200 Organization: 1&1 Internet AG Message-ID: NNTP-Posting-Host: p57b60537.dip0.t-ipconnect.de Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: online.de 1223071743 7170 87.182.5.55 (3 Oct 2008 22:09:03 GMT) X-Complaints-To: abuse@einsundeins.com NNTP-Posting-Date: Fri, 3 Oct 2008 22:09:03 +0000 (UTC) X-message-flag: IMPORTANT MESSAGE -- PLEASE READ IMMEDIATELY!!! X-Accepted-File-Formats: ASCII, .rtf, .ps, .pdf - *NO* MS Office files User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) Xref: g2news2.google.com comp.lang.ada:7951 Date: 2008-10-04T00:08:54+02:00 List-Id: Hi, I've a problem with a representation that I don't understand. And I'm pretty sure older versions of gnat than 4.3 had a different behaviour. This stuff compiles as I expect with gnat 4.3 (on Debian Lenny): with Ada.Text_Io; procedure Align is type Compound is record A : Boolean; B : Integer; C : Integer; end record; for Compound use record A at 0 range 0 .. 0; B at 2 range 0 .. 31; C at 6 range 0 .. 31; end record; type C_Array is array (Natural range <>) of Compound; for C_Array'Component_Size use 80; Size : Natural := Compound'Size; begin Ada.Text_Io.Put_Line ("Compound has size" & Natural'Image(Size)); end Align; ~/myprogs/test $ gnatmake align gcc-4.3 -c align.adb gnatbind -x align.ali gnatlink align.ali ~/myprogs/test $ ./align Compound has size 80 ~/myprogs/test $ Now if I move component A of the record to the end as in ... type Compound is record B : Integer; C : Integer; A : Boolean; end record; for Compound use record B at 0 range 0 .. 31; C at 4 range 0 .. 31; A at 8 range 0 .. 0; end record; ... ~/myprogs/test $ gnatmake align gcc-4.3 -c align.adb align.adb:16:09: component size for "C_Array" too small, minimum allowed is 96 gnatmake: "align.adb" compilation error ~/myprogs/test $ And if i remove the line 'for C_Array'Component_Size use 80;' so the program compiles I get ~/myprogs/test $ gnatmake align gcc-4.3 -c align.adb gnatbind -x align.ali gnatlink align.ali ~/myprogs/test $ ./align Compound has size 65 So we see Compound should definitivly fit into 80 bits. Obviously gnat wants to align to DWORD boundaries in the 2nd case but not in the 1st. Why and what can I do about it?