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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,4bd6ca8f7a1eb225 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Received: by 10.68.15.41 with SMTP id u9mr6479768pbc.3.1322103058710; Wed, 23 Nov 2011 18:50:58 -0800 (PST) Path: lh20ni11221pbb.0!nntp.google.com!news2.google.com!postnews.google.com!b32g2000yqn.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Class with task destructor Date: Wed, 23 Nov 2011 18:48:53 -0800 (PST) Organization: http://groups.google.com Message-ID: <40710291-64ed-46b8-9106-40b7d481effd@b32g2000yqn.googlegroups.com> References: <30604696.94.1322013045135.JavaMail.geo-discussion-forums@yqzz20> <80027d05-2740-4899-b43a-514100ec9bd2@p16g2000yqd.googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 X-Trace: posting.google.com 1322103058 11679 127.0.0.1 (24 Nov 2011 02:50:58 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 24 Nov 2011 02:50:58 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: b32g2000yqn.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: ARLUEHNKC X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618; .NET4.0C),gzip(gfe) Xref: news2.google.com comp.lang.ada:14585 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2011-11-23T18:48:53-08:00 List-Id: On Nov 23, 4:15=A0pm, "Randy Brukardt" wrote: > > >*Any* use of Unchecked_Deallocation can lead to a dangling reference, > >which is why it's called Unchecked. =A0But also note that the language > >explicitly says that if you use Unchecked_Deallocation on an object > >that contains tasks, the object might not actually disappear > >(13.11.2(9)). =A0I'm not sure if there are language rules that say that > >the object *must* not be deallocated immediately in a case like this, > >where the task has a discriminant that refers to the object being > >freed. =A0I don't have time to look into it at the moment. =A0Maybe > >someone else knows? > > The task continues to run (always) through a UC. The compiler has to ensu= re > that works, and if that means not deallocating the object, that would wor= k. > Janus/Ada doesn't work this way, all of the task information is in the TC= B > and there is no connection to the enclosing object. Except that in the OP's case, there *is* a connection: the task has an access discriminant that will refer to the enclosing object, and if the task keeps running, it could use that discriminant. That's what I wanted to know--in a case like that, are there language rules that say the object can't be deallocated until the task has completed; or does the access discriminant just become a dangling reference? Or does Janus/Ada (or any other compiler) treat cases like this specially so that the access discriminant is still valid? Since Unchecked_Deallocation is always capable of creating dangling references, maybe this case isn't so special; I was just wondering whether this is a special case at all, since off the top of my head it seems that objects that contain self-references through access discriminants can't lead to dangling references (through those self- references) when the objects are deallocated, *unless* they involve a task that keeps running as in this case. -- Adam