From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-65-14.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-3.2 required=3.0 tests=BAYES_00,NICE_REPLY_A, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R.Carter" Newsgroups: comp.lang.ada Subject: Re: Is this a compiler bug ? Date: Sun, 19 Mar 2023 11:33:50 +0100 Organization: A noiseless patient Spider Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Sun, 19 Mar 2023 10:33:50 -0000 (UTC) Injection-Info: reader01.eternal-september.org; posting-host="1685dfc620336490cc1144d3a5e89925"; logging-data="3100118"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ichck1f76DeZirGYnNTuWOqW7Jcdsoo4=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Cancel-Lock: sha1:HK1cdhBH1jhr2WZYDDrvO0VJm0c= Content-Language: en-US In-Reply-To: Xref: reader01.eternal-september.org comp.lang.ada:65005 List-Id: On 2023-03-19 07:17, Rod Kay wrote: > >    In the 'to_Stack' function, the Capacity is reserved correctly but in the > test program when the stack is created and assigned to a variable, the capacity > is 0. I think this is acceptable behavior. See ARM A.18.2 (147.19/3, 147.20/3, & 147.b/3) (http://www.ada-auth.org/standards/aarm12_w_tc1/html/AA-A-18-2.html). The first two sections define the behavior of procedure Assign, while the last states "Assign(A, B) and A := B behave identically". Assign (A, B) only changes the capacity of A if A.Capacity < B.Length. So if the compiler does not use build-in-place for the initialization of the variable, then the assignment of the function result should not change the capacity of the variable from its (apparent) default of zero (there is, of course, no requirement for the capacity of a default-initialized vector). The discussion of capacities for vectors is only meaningful for a subset of possible implementations, so messing with capacities may have no meaningful effect at all. For an unbounded stack based on a linked list (with no concept of capacity) you could use PragmARC.Data_Structures.Stacks.Unbounded.Unprotected (https://github.com/jrcarter/PragmARC/blob/Ada-12/pragmarc-data_structures-stacks-unbounded-unprotected.ads). -- Jeff Carter "Since I strongly believe that overpopulation is by far the greatest problem in the world, this [Soylent Green] would be my only message movie." Charleton Heston 123