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!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: Reference counter in smart pointers are not updated properly when used by multiple tasks Date: Thu, 1 Feb 2018 21:12:37 +0100 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <2a706673-45d2-4cfa-805f-4a7d0086f721@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 1 Feb 2018 20:12:38 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="d00a48bca5dfe0f5f0b7287eda11020b"; logging-data="31071"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+u8j6rahM4DCW0mtgH5J1LN/f9351q3II=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 In-Reply-To: <2a706673-45d2-4cfa-805f-4a7d0086f721@googlegroups.com> Content-Language: en-US Cancel-Lock: sha1:CgnO/w8W1r9p460MKDZEdaBe5a4= Xref: reader02.eternal-september.org comp.lang.ada:50262 Date: 2018-02-01T21:12:37+01:00 List-Id: On 02/01/2018 08:37 PM, onox wrote: > On Thursday, February 1, 2018 at 3:48:10 PM UTC+1, Jeffrey R. Carter wrote: >> Set's parameter Free is an anonymous access-to-subprogram parameter; one is not >> supposed to be able to assign those and call them later, but that is exactly >> what this code does. Is this code legal? GNAT compiles it fine. If it is legal, >> should it be? > > I hope so. When I instantiate the Orka.Smart_Pointers package, I do not know how to free the Object_Type (access to an interface). Only when I call Set I know how to free the object (access to a tagged type implementing the interface). AIUI, it should be illegal. Because Ada has nested subprograms, it's possible that the subprogram won't exist when you call it. To prevent that from happening is why named access-to-subprogram types are subject to accessibility checks. Anonymous access-to-subprogram parameters don't have such checks because you're not supposed to be able to copy them. -- Jeff Carter "My mind is aglow with whirling, transient nodes of thought, careening through a cosmic vapor of invention." Blazing Saddles 85