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,582882cfea9f35db X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-01-12 05:25:33 PST Path: supernews.google.com!sn-xit-02!supernews.com!news.gv.tsc.tdk.com!news.iac.net!news-out.cwix.com!newsfeed.cwix.com!europa.netcrusader.net!152.163.239.129!portc01.blue.aol.com!news-out.usenetserver.com!newsfeed2.earthlink.net!newsfeed.earthlink.net!newsmaster1.prod.itd.earthlink.net!newsread2.prod.itd.earthlink.net.POSTED!not-for-mail Message-ID: <3A5EF610.66C153D2@earthlink.net> From: "Marc A. Criley" Organization: Quadrus Corporation X-Mailer: Mozilla 4.73 [en] (X11; U; Linux 2.2.14-5.0 i686) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Green Hiils AdaMULTI 2000 -> Motorola Coldfire References: <93igkj$grt$1@lure.pipex.net> <3A5DC6D5.5A8446D8@hercii.mar.lmco.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Fri, 12 Jan 2001 13:18:49 GMT NNTP-Posting-Host: 158.252.122.236 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.prod.itd.earthlink.net 979305529 158.252.122.236 (Fri, 12 Jan 2001 05:18:49 PST) NNTP-Posting-Date: Fri, 12 Jan 2001 05:18:49 PST Xref: supernews.google.com comp.lang.ada:3949 Date: 2001-01-12T13:18:49+00:00 List-Id: One other aspect regarding 'Size, types, and subtypes. This one bit us when porting from Alsys Ada 83 to GNAT. If a type has a 'Size clause applied to it, specifying a size larger than what is actually required, and a subtype off that type is defined, the subtype does _not_ inherit the parent's size specification. For example: type Counts is range 0..128; for Counts'size use 32; subtype Subcounts is Counts range 1..128; then Counts'Size is 32 Subcounts'Size is 8 This is caused by a gap in the Ada 95 definition regarding "sizes", which I think Robert Dewar alluded to in an earlier message. I don't recall the LRM reference that results in this behavior, but it's defininely there and one is barred from making the behavior otherwise. I recall, though, ACT informing me that _objects_ of either of those Counts or Subcounts types would occupy the requested 32 bits (and they do in GNAT)--I believe there was some implementation freedom regarding that aspect. In the few places where we had to deal with this situation, we simply replaced the subtype with the parent type at, and only at, the place where the difference in size had an effect. Everywhere else we continued to use the subtype to ensure proper type constraining. Marc A. Criley Senior Staff Engineer Quadrus Corporation www.quadruscorp.com Brian Courtney wrote: > > We recently ported a 200,000+ sloc app (MIPS) from Ada83 (Aonix) > to GHS Ada95 as part of an evaluation of the AdaMULTI2000 > environment. The only problem we experienced was not > with the compiler/environment, rather some bad assumptions > made by the original developers about the size of subtypes. > NOTE: The language does not require objects of a subtype to > be the same size as objects of the parent type. As you > might expect, the two compilers implemented this differently. > The Aonix Ada83 compiler would preserve the size of subtypes > from the parent type and the GHS Ada95 compiler would not (it > seemed to chose the smallest size possible based on the range > of the subtype). Either implementation is allowed by the language. > > A misunderstanding by the developers, or an oversight in the > language? Either way, this issue has plagued more than one > project, so it may be something you want to be on the lookout for. > I've used XDAda in the past, but can't recall its behavior. In any > event, the moral of the story is "don't assume the size of a subtype". > > Hope this helps, > > Brian Courtney