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: Ada.Containers and concurrent modification exception. Date: Wed, 19 Sep 2018 22:16:15 +0200 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Wed, 19 Sep 2018 20:16:17 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="a0aa416f830bed1d628e55d44ca1a29a"; logging-data="26516"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1++e0RzJFG+8aLQTZBWXQ0Kw00afh3zNIU=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 Cancel-Lock: sha1:3dhZQIq78htD+p2E7KM59fzCCv4= In-Reply-To: Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:54381 Date: 2018-09-19T22:16:15+02:00 List-Id: On 09/19/2018 03:12 PM, rakusu_klein@fastmail.jp wrote: > > with Ada.Containers.Indefinite_Ordered_Maps; > ... > The_Map : Map; > ... > declare > I : Cursor := First (The_Map); > J : Cursor := First (The_Map); > begin > -- Now Cursors are synchronized with each other and with a container. > Delete (The_Map, I); > -- It's O'k. But now J lost a sync and points to a dead Node. > Next (J); > -- What should I expected here, > -- any well defined exception or > -- raising a zombie? > end; The ARM covers this case in ARM A.18.4(76-80) [I am unable to access the current ARM right now, so I'm quoting from ISO/IEC 8652:2007, which should be similar]: "A Cursor value is invalid if ... The node it designates has been deleted from the map. The result of "=" or Has_Element is unspecified if these functions are called with an invalid cursor parameter. Execution is erroneous if any other subprogram declared in Containers.Hashed_Maps or Containers.Ordered_Maps is called with an invalid cursor parameter. So J is invalid and Next (J) is erroneous. ARM 1.1.5(10) defines erroneous execution: "there is no language-specified bound on the possible effect of erroneous execution; the effect is in general not predictable." In other words, this call can do anything. -- Jeff Carter "I spun around, and there I was, face to face with a six-year-old kid. Well, I just threw my guns down and walked away. Little bastard shot me in the ass." Blazing Saddles 40