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,f2690a5e963b61b6 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news.maxwell.syr.edu!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.megapath.net!news.megapath.net.POSTED!not-for-mail NNTP-Posting-Date: Wed, 06 Jul 2005 22:21:02 -0500 From: "Randy Brukardt" Newsgroups: comp.lang.ada References: <1120474891.635131.216700@g44g2000cwa.googlegroups.com> <1120575076.876798.108220@g44g2000cwa.googlegroups.com> <1120583470.429264.325450@g43g2000cwa.googlegroups.com> Subject: Re: GCC 4.0 Ada.Containers Cursor danger. Date: Wed, 6 Jul 2005 22:24:10 -0500 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4952.2800 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4952.2800 Message-ID: NNTP-Posting-Host: 64.32.209.38 X-Trace: sv3-wew1w0fztgdLH0ia+QyJ8ZnhabkiRTxqtCplkl6kE+6QxCuxsm+Ie6YDGQRwwFncR/vLvpOs8/av/3q!ZGmb8zU3gRy1e/Z+1T2/k+VTFa1J118Oy+N9oWSU/9BmQryxK2hMic4UJZiEfoLqqfO0t/jGQzY+ X-Complaints-To: abuse@megapath.net X-DMCA-Complaints-To: abuse@megapath.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.32 Xref: g2news1.google.com comp.lang.ada:11921 Date: 2005-07-06T22:24:10-05:00 List-Id: "Matthew Heaney" wrote in message news:uslyrv50w.fsf@earthlink.net... > To make things absolutely bullet-proof, I think you'd need at least a > per-element reference count. (That, or have the container maintain a > list of extant cursors, which you would then have to search.) If you > attempt to delete a node for which the ref count is greater than 0, then > you could raise an exception. (This might actually produce a false > positive, since the real error is attempting to dereference the cursor, > not merely delete the node to which it is bound. But to solve that, > you'd have to move the node onto a free list, and during the dereference > check to see whether the node is on the free list or not.) It just struck me that this implementation would be wrong. The execution doesn't become erroneous until the programmer uses the dangling cursor. Raising some exception before the execution becomes erroneous wouldn't be right. I think that a scheme where the cursors were all linked to the container (or element) would be needed to be completely bullet-proof (and correct). Then the cursors could be marked as deleted when the element deleted or the container is finalized. But that could have a lot of overhead. Randy.