Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Sex dumps core (Sex is a Simple editor for X11) -- Seen on debian bugtracking


devel / comp.lang.ada / Is this a compiler bug ?

SubjectAuthor
* Is this a compiler bug ?Rod Kay
`* Re: Is this a compiler bug ?Jeffrey R.Carter
 `- Re: Is this a compiler bug ?Rod Kay

1
Is this a compiler bug ?

<tv69dh$2srvk$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9408&group=comp.lang.ada#9408

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: rodakay5@gmail.com (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
Lines: 30
Message-ID: <tv69dh$2srvk$1@dont-email.me>
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
 by: Rod Kay - Sun, 19 Mar 2023 06:17 UTC

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.

Re: Is this a compiler bug ?

<tv6oee$2ujem$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9409&group=comp.lang.ada#9409

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: spam.jrcarter.not@spam.acm.org.not (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
Lines: 34
Message-ID: <tv6oee$2ujem$1@dont-email.me>
References: <tv69dh$2srvk$1@dont-email.me>
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: <tv69dh$2srvk$1@dont-email.me>
 by: Jeffrey R.Carter - Sun, 19 Mar 2023 10:33 UTC

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

Re: Is this a compiler bug ?

<tv8g59$38oos$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9410&group=comp.lang.ada#9410

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: rodakay5@gmail.com (Rod Kay)
Newsgroups: comp.lang.ada
Subject: Re: Is this a compiler bug ?
Date: Mon, 20 Mar 2023 13:24:40 +1100
Organization: A noiseless patient Spider
Lines: 39
Message-ID: <tv8g59$38oos$1@dont-email.me>
References: <tv69dh$2srvk$1@dont-email.me> <tv6oee$2ujem$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 20 Mar 2023 02:24:42 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="7b118bbe60abd8dc27d15111e7b55641";
logging-data="3433244"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+M4b2uBsxmcz1WutB82TGZm32loMxO6Gs="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.8.0
Cancel-Lock: sha1:QF6CpgkW0AXW3UsQDv9t1Q/851g=
In-Reply-To: <tv6oee$2ujem$1@dont-email.me>
Content-Language: en-US
 by: Rod Kay - Mon, 20 Mar 2023 02:24 UTC

On 19/3/23 21:33, Jeffrey R.Carter wrote:
> 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).
>

Thank you, Jeffrey, for the detailed reply.

I'm now using a limited record with an extended return for
'build-in-place' initialisation and am getting the behavior I desired.

Cheers.


devel / comp.lang.ada / Is this a compiler bug ?

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor