From: "John B. Matthews" <nospam@nospam.invalid>
Subject: Re: Vectors.Insert_Space bug?
Date: Wed, 20 May 2009 21:56:44 -0400
Date: 2009-05-20T21:56:44-04:00 [thread overview]
Message-ID: <nospam-A1749E.21564420052009@news.aioe.org> (raw)
In-Reply-To: 4a146f41$0$90265$14726298@news.sunsite.dk
In article <4a146f41$0$90265$14726298@news.sunsite.dk>,
Thomas Løcke <thomas.granvej6@gmail.com> 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...":
<http://www.adaic.com/standards/05rm/html/RM-A-18-2.html>
--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>
next prev parent reply other threads:[~2009-05-21 1:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-20 20:59 Vectors.Insert_Space bug? Thomas Løcke
2009-05-21 1:56 ` John B. Matthews [this message]
2009-05-22 5:07 ` Thomas Løcke
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox