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!postnews.google.com!g49g2000cwa.googlegroups.com!not-for-mail From: "Matthew Heaney" Newsgroups: comp.lang.ada Subject: Re: GCC 4.0 Ada.Containers Cursor danger. Date: 20 Jul 2005 07:34:49 -0700 Organization: http://groups.google.com Message-ID: <1121870089.752445.108320@g49g2000cwa.googlegroups.com> References: <1120474891.635131.216700@g44g2000cwa.googlegroups.com> <1121573057.159416.274980@g49g2000cwa.googlegroups.com> <1121622050.676894.246740@g14g2000cwa.googlegroups.com> <%q%Ce.11640$1Y1.7177@fe02.lga> NNTP-Posting-Host: 66.162.65.162 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1121870095 8602 127.0.0.1 (20 Jul 2005 14:34:55 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 20 Jul 2005 14:34:55 +0000 (UTC) In-Reply-To: User-Agent: G2/0.2 Complaints-To: groups-abuse@google.com Injection-Info: g49g2000cwa.googlegroups.com; posting-host=66.162.65.162; posting-account=Zl1UPAwAAADEsUSm1PMMiDjihtBlZUi_ Xref: g2news1.google.com comp.lang.ada:3701 Date: 2005-07-20T07:34:49-07:00 List-Id: Pascal Obry wrote: > > That such problem could occur again. We must ensure that at least the > documentation is clear (very clear) about the semantics here. Cursors confer no greater safety than you get with named access types. If this isn't clear, then yes, we need to better job of advertising this feature. In general, don't keep cursors around unless you have a good reason. And if you have a key (this is a map, say), then you can always use key-based operations instead of cursor-based ones. (In Dmitriy's case, he should have been using Include or Replace, not Replace_Element.) > I'm not saying that Ada.Containers or Cursor are bad, I already like this > library much (this is not the case for Dmitriy :), what I'm saying is that > this problem could happen to others and it is dangerous enough for us to take > great care about it :) I took Dmitriy's complaint seriously enough that I've been adding assertion checks that can detect dangling cursors. (When you build his original example with assertions enabled, the program now fails with a nice error message.)