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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,276adc24c378e1af,start X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!news.glorb.com!news2.glorb.com!dotsrc.org!filter.dotsrc.org!news.dotsrc.org!not-for-mail Date: Wed, 20 May 2009 22:59:45 +0200 From: =?ISO-8859-1?Q?Thomas_L=F8cke?= Organization: Ada DK User-Agent: Thunderbird 2.0.0.21 (X11/20090302) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Vectors.Insert_Space bug? Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Message-ID: <4a146f41$0$90265$14726298@news.sunsite.dk> NNTP-Posting-Host: 83.91.213.86 X-Trace: news.sunsite.dk DXC=mT1^Ha]>fQONc7PehKo47KYSB=nbEKnkKMBJNHnHdcJOE1G X-Complaints-To: staff@sunsite.dk Xref: g2news2.google.com comp.lang.ada:5965 Date: 2009-05-20T22:59:45+02:00 List-Id: Hey all, 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: -- Pasted code start -- with Ada.Text_IO.Unbounded_IO; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Containers.Vectors; use Ada.Containers; procedure Test is package SUIO renames Ada.Text_IO.Unbounded_IO; package US_Container is new Vectors (Positive, Unbounded_String); Testing : US_Container.Vector; begin Testing.Append (New_Item => To_Unbounded_String ("Item 1")); Testing.Append (New_Item => To_Unbounded_String ("Item 2")); Testing.Append (New_Item => To_Unbounded_String ("Item 3")); Testing.Append (New_Item => To_Unbounded_String ("Item 4")); Testing.Append (New_Item => To_Unbounded_String ("Item 5")); Testing.Insert_Space (Before => 5, Count => 3); for i in 1 .. Testing.Length loop SUIO.Put_Line (i'Img & " " & Testing.Element (Integer (i))); end loop; end Test; -- Pasted code end -- 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. Regards, Thomas L�cke