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=-0.9 required=3.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 Path: eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Rod Kay Newsgroups: comp.lang.ada Subject: Is this a compiler bug ? Date: Sun, 19 Mar 2023 17:17:20 +1100 Organization: A noiseless patient Spider Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sun, 19 Mar 2023 06:17:21 -0000 (UTC) Injection-Info: reader01.eternal-september.org; posting-host="ca1f6995f3ca0da44d8287ea1baedb5c"; logging-data="3043316"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/dXOlCmGHD+IhG5XBqv7rxvhUK4M3AgOE=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Cancel-Lock: sha1:HVrX24roEwCKLlIN5DI+BJFTBBw= Content-Language: en-US Xref: reader01.eternal-september.org comp.lang.ada:65004 List-Id: Hi all, Came across this during a port of the Box2D physics engine. It's a generic Stack package using 'ada.Containers.Vectors' to implement the stack. One generic parameter is the 'initial_Capacity' of the stack, used in the 'to_Stack' construction function, via the Vectors 'reserve_Capacity' procedure. 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. Here is the (very small) source code ... https://gist.github.com/charlie5/7b4d863227a510f834c2bfd781dd50ba The output I get with GCC 12.2.0 is ... [rod@orth bug]$ ./stack_bug to_Stack ~ Initial Capacity: 256 to_Stack ~ Before reserve: 0 to_Stack ~ After reserve: 256 stack_Bug ~ Actual Capacity: 0 Regards.