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,LOTS_OF_MONEY autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,276adc24c378e1af X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,UTF8 Path: g2news2.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!news.in2p3.fr!in2p3.fr!news.ecp.fr!aioe.org!nospam From: "John B. Matthews" Newsgroups: comp.lang.ada Subject: Re: Vectors.Insert_Space bug? Date: Wed, 20 May 2009 21:56:44 -0400 Organization: The Wasteland Message-ID: References: <4a146f41$0$90265$14726298@news.sunsite.dk> NNTP-Posting-Host: ib4TTflHUauJidfWP/+Rjw.user.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.7.9 Cancel-Lock: sha1:A9K9KHRnox4UXH973dHVHx3WkXQ= User-Agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) Xref: g2news2.google.com comp.lang.ada:5966 Date: 2009-05-20T21:56:44-04:00 List-Id: In article <4a146f41$0$90265$14726298@news.sunsite.dk>, Thomas Løcke wrote: > I've stumbled on some weird behavior while trying to make use of the > Ada.Containers.Vectors.Insert_Space procedure. According to the RM, this > is what it should do: > > "... Then Insert_Space slides the elements in the range Before .. > Last_Index (Container) up by Count positions, and then inserts empty > elements in the positions starting at Before." > > But that is not at all what I'm seeing, as this small test-program will > show: [...] > The output from the Test program is: > > 1 Item 1 > 2 Item 2 > 3 Item 3 > 4 Item 4 > 5 Item 5 > 6 > 7 > 8 Item 5 > > Which IMHO is wrong. There shouldn't be two "Item 5" elements. And it's > possible to make it even worse, by calling Insert_Space multiple times > with different Before and Count parameters. > > It seems as if the element located at the Before index is copied and > inserted as the first new element, and only after that, does > Insert_Space actually start inserting empty elements. > > I've tried to compile with two different compilers, and both exhibit > this odd behavior: > GNATMAKE 4.2.3 > GNATMAKE GPL 2008 (20080521) > > I admit to just being a hobbyist, so this might just be me not "getting" > what the RM is trying to tell me, but I do think the text is fairly clear. > > Any help would be greatly appreciated. I get the same result with 4.3.4. It looks like the old element 5 slid to position 8. The three empties are at positions 5, 6 and 7. Note that "Empty elements do not have a specified value." In particular, "Reading the value of an empty element by calling Element" is a bounded error, and "The implementation may treat the [empty] element as having any normal value...": -- John B. Matthews trashgod at gmail dot com