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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Error: "non-local pointer cannot point to a local object" Date: Wed, 12 Sep 2018 17:22:55 +0200 Organization: Aioe.org NNTP Server Message-ID: References: <7a6b1ae7-f142-458d-ab01-c36c8ed30659@googlegroups.com> <9a44824f-2897-48f0-92b1-3e9528147ef6@googlegroups.com> NNTP-Posting-Host: MyFhHs417jM9AgzRpXn7yg.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 Content-Language: en-US X-Notice: Filtered by postfilter v. 0.8.3 Xref: reader02.eternal-september.org comp.lang.ada:54334 Date: 2018-09-12T17:22:55+02:00 List-Id: On 2018-09-12 16:47, NiGHTS wrote: > On Wednesday, September 12, 2018 at 3:26:46 AM UTC-4, Dmitry A. Kazakov wrote: > >> What goal? It looks like a bad design. Copying pointers to integers is >> asking for trouble. > > The integer was chosen to simplify the example. In the actual application it is a tree container, where there is a single thread that is expected to manipulate various contexts of the same tree, thus multiple working records for the same tree. Why do you need copying? By-reference semantics does not match copying (= by-value). >> BTW, if you used Ada.Finalization.Controlled, as you likely should, and >> derived one record from another then default copying before Adjust would >> copy pointer too. What would happen with access info, I have no idea, >> probably copied as-is. (Yet another reason not to use anonymous access >> types inside records unless for Rosen's trick or access-to-constant) >> > While my example does not show Ada.Finalization.Controlled in use, my application's record indeed is derived from this object. Still, I am not sure how overriding Adjust would be applied to my example. Would you show me a quick and dirty example of how this would be done? Before Adjust is called an exact copy of the controlled source object is made. This naturally applies to its access components as well. Thus you probably need not to override Adjust at all. [ As I said I don't know what happens with the accessibility checks. Where assignment of plain records fail, would assignment of controlled ones fail as well, if Adjust is null? ] -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de