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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: hreba Newsgroups: comp.lang.ada Subject: Re: How can one record component be local and another not? Date: Tue, 5 May 2020 14:59:18 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net oZWcDUJj81F/3GyVaef/wgEMBYtGwunx6l/6uR5ojlgh3ByPjr Cancel-Lock: sha1:fDTbXV2uxD+aNlWNqtGw5LAs3Gw= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 In-Reply-To: Content-Language: de-DE Xref: reader01.eternal-september.org comp.lang.ada:58584 Date: 2020-05-05T14:59:18+02:00 List-Id: On 5/5/20 1:33 PM, AdaMagica wrote: > Am Dienstag, 5. Mai 2020 13:04:56 UTC+2 schrieb hreba: >> I have reduced my problem to the following example: >> >> package Aux is >> type Integer_P is access all Integer; >> type Rec is record >> a: aliased Integer; >> p: Integer_P; >> end record; >> >> procedure Init (r: in out Rec); >> end Aux; >> >> package body Aux is >> procedure Init (r: in out Rec) is >> begin >> r.p:= r.a'Access; -- <-- error! >> end Init; >> end Aux; > > Imagine you define a local Rec: > > with Aux; > procedure Proc is > R: Aux.Rec; > begin > Aux.Init (R); > end Proc; > > Now R has shorter lifetime than the access type Integer_P. Thus you might have somewhere an access object AO with longer lifetime than R and try to assign > AO := R.P; > > Try Unrestricted_Access. > Don't understand that. R.a and R.p have exactly the same lifetime, which is the lifetime of R, haven't they? -- Frank Hrebabetzky, Kronach +49 / 9261 / 950 0565