From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 31 Aug 93 20:36:04 GMT From: dog.ee.lbl.gov!agate!howland.reston.ans.net!math.ohio-state.edu!magnus.ac s.ohio-state.edu!csn!news.den.mmc.com!iplmail!alcyone!rgilbert@ucbvax.Berkeley. EDU (Bob Gilbert) Subject: Re: Data Overlays Message-ID: <1993Aug31.203604.29444@iplmail.orl.mmc.com> List-Id: In article 29091@software.org, smithd@software.org (Doug Smith) writes: >In article <1993Aug18.125540.1393@iplmail.orl.mmc.com> rgilbert@orl.mmc.com wr ites: >> >>As far as the technique of: >> >> X : TYPE_1; >> Y : TYPE_2; >> for Y use at X'address; >> >>The LRM 13.5 states that address clauses should not be used to achieve overla ys >>of objects... Any program using address clauses to achieve such effects is >>erroneous. What is the rationale for this? >> >> [stuff deleted] >> >> Bob > > >And...if you use this technique, don't forget what happens when the >variable is elaborated: > > procedure P(X : Some_Type) is > Y : Some_Pointer_Type; -- or record with initialization > for Y use at X'Address; > begin > -- Y has likely been initialized to null, and X has probably > -- been changed. But, since this program is erroneous, > -- it is fine for the compiler to do whatever it wants ;^) > end; > >Doug >smithd@software.org Absolutely, and somewhat unrelated to data overlays... I have experienced this and it can be a problem when attempting to map to read-only (VME bus system) addresses. Since most compilers will attempt to initialize objects using representation clauses, during program elaboration the resulting write to the address results in a VME bus error. The solution is to use access types and assign the address to the access object using Unchecked_Conversion. This BTW, is similar to the other method I have used for implementing data overlays. Bob