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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8247c32bb1260c74 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-04-22 15:51:51 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: mheaney@on2.com (Matthew Heaney) Newsgroups: comp.lang.ada Subject: Re: Q re pack & aliased Date: 22 Apr 2003 15:51:51 -0700 Organization: http://groups.google.com/ Message-ID: <1ec946d1.0304221451.6365ec93@posting.google.com> References: NNTP-Posting-Host: 66.162.65.162 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1051051911 23803 127.0.0.1 (22 Apr 2003 22:51:51 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 22 Apr 2003 22:51:51 GMT Xref: archiver1.google.com comp.lang.ada:36381 Date: 2003-04-22T22:51:51+00:00 List-Id: tmoran@acm.org wrote in message news:... > >The first True-Color-VGA had 24-bit-sized pixels. How would you have > >addressed them? > I have pre-Gnat 3.15p programs that ran with 24 bit pixels, so this > is apparently a new problem. Would someone with a newer Gnat please > try the program below? On 3.15p it gives a warning on aliased, and ignores > the packing. Removing the word "aliased" makes it pack correctly. > > with ada.text_io; > procedure testpack is > type triples is range 0 .. 2**24-1; > for triples'size use 24; > type bunches is array(integer range <>) of aliased triples; > pragma pack(bunches); > x : bunches(1 .. 10); > begin > ada.text_io.put_line(integer'image(x'size/80) > & " should = 3, not 4"); > end testpack; Pragma Pack and aliased components don't really go together. Think about it: the pragma is there to tell the compiler not to allocate array components on "natural" boundaries, which would otherwise be addressable. Get rid of the pragma Pack, and use a component size clause: type bunches is array (integer range <>) of aliased triples; for bunches'Component_Size use 24; Pragma Pack is really intended to give a hint to the compiler that you wish to make a space optimization -- do not use it to specify representation. That's what the T'Component_Size is for. Don't use pragma Pack unless you know what you're doing. Your program is broken.