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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ffdd4d59cbfb4caf X-Google-Attributes: gid103376,public From: dewar@merv.cs.nyu.edu (Robert Dewar) Subject: Re: Ada 95 Numerics questions for the experts Date: 1997/09/06 Message-ID: #1/1 X-Deja-AN: 270371451 References: Organization: New York University Newsgroups: comp.lang.ada Date: 1997-09-06T00:00:00+00:00 List-Id: Bob said <for arr8'Component_Size use 1; > >instead of > >pragma Pack (arr8); both of the above will result in arr8'Component_Size = 1, and arr8'Size = 8.>> This is surpringly wrong. Bob, you must go read the RM, it was written by this clever fellow Bob Duff, and will tell you the TRUTH :-) :-) First, in the absence of implementation of annex C, neither declaration will guarantee close packing. In the presence of close packing, it is true that both will guarantee this, but given the two declarations pragma Pack (array_type); for array_type'component_size use array_component_type'size; it is never the case that, as suggested by Bob Duff's quote, that the second form is somehow more exact than the first. I find this odd, but then I did not write the RM! There are two issues to consider 1. Is annex C implemented? If not, then either of these declarations on their own may have no effect. 2. If annex C is implemented, then is the component size or size of the component a factor or multiple of the word size? if yes, then either of these two declarations will do the job if NOT, then pragma Pack is stronger because it will do no worse than go up to the next factor (e.g. 3 moved to 4), but a component size clause can be completely ignored, since there is no requirement to implement component clauses in this case (technically what you do is to accept the component claiuse, but then implement allowed gaps), Note that using BOTH clauses together is useful, since in this case, the RM guarantees that a compiler that accepts the clauses, even if it does not implment Annex C, MUSt do the right thing. Odd eh?