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,c5eac035c8f1d2be X-Google-Attributes: gid103376,public From: dewar@cs.nyu.edu (Robert Dewar) Subject: Re: Record component positions always constant? Date: 1996/05/26 Message-ID: #1/1 X-Deja-AN: 156842532 references: <4o9h6c$3rk@goanna.cs.rmit.EDU.AU> organization: Courant Institute of Mathematical Sciences newsgroups: comp.lang.ada Date: 1996-05-26T00:00:00+00:00 List-Id: Dale asked: "Will the positions of the components in a record (for a given subtype) remain constant even in the presence of fields whose lengths depend on a discriminant (excluding of course variant records) for all (likely) Ada implementations?" The answer is NO for all likely Ada implementations, a subtype is required to take only as much space as it needs. One can imagine an imlementatoin that uses hidden heap pointers for variable length components depending on discriminants, but in practice virtually all (all?) implementations store the variable length field in place. Some implementations store extra offset components to help them find their way past such components (old Alsys technology does this in the absence of some pragma (I forget the details of he pragma). Other implementations (Dec, GNAT, Alsys with that pragma), recompute their way past the variable length fields from the discriminant values on each reference. To give a very specific example: type R (N : Natural) is record S1 : String (1 .. N); S2 : String (1 .. N); end record; the offset of component S2 will typically vary with the value of N. There is an ACVC test that ensures that no implementation uses allocate-the-maximum for such individual fields.