comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Bug in GNAT? - Max_size_in_storage_elements insufficient
Date: Wed, 19 Oct 2016 19:59:08 -0500
Date: 2016-10-19T19:59:08-05:00	[thread overview]
Message-ID: <nu94rr$gq1$1@franka.jacob-sparre.dk> (raw)
In-Reply-To: 647636100.498533813.258228.laguest-archeia.com@nntp.aioe.org

"Luke A. Guest" <laguest@archeia.com> wrote in message 
news:647636100.498533813.258228.laguest-archeia.com@nntp.aioe.org...
> Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> wrote:
>
>>> Well, then it's at least a bug in [Barnes] because there's an example
>>> like the above ones just with a simpler type. But I still think the idea
>>> here is/was to provide enough space for N items of some type.
>>
>> I am not sure if that were technically possible. Considering an
>> implementation of, for example, a marked-margins pool, the penalty to
>> have a guarantee would be extremely high.
>
> Surely that's what a static language can supply, the actual amount of 
> space
> required?

Depends on the implementation of the storage pool, of course. The amount of 
memory used by objects can be figured out at compile-time (assuming that the 
subtype is definite and there aren't any discriminant-dependent components - 
it's possible to declare such objects non-contiguously), but the pool will 
have some overhead.

Besides, that's irrelevant. S'Max_Storage_Size_in_Elements is not a static 
attribute and thus doesn't have to be calculatable at compile-time. The OP's 
example is legal because the value of Storage_Size doesn't have to be 
static, either. Of course, that means that whatever the OP is trying to do 
probably isn't going to happen here.

Turning to the OP's question:

I would never expect to be able say anything useful about the size of a task 
object - it's going to have to be allocated in pieces all over the memory 
map (there's limits on where the stack can be allocated, for instance). No 
attribute (Size, Object_Size, Max_Storage_Size_in_Elements) can have 
anything useful to say about non-contiguous objects.

Note: I've always interpreted Max_Storage_Size_in_Elements to apply to a 
single call to Allocate; there might be multiple calls to Allocate to 
allocate a single object (Janus/Ada works this way; there is a separate call 
to Allocate for each contiguous part of an object). Indeed, I wrote the 
definition of the attribute with this model in mind. Whether any other Ada 
lawyers would agree with me is unclear. :-)

                          Randy.





  parent reply	other threads:[~2016-10-20  0:59 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-18 11:17 Bug in GNAT? - Max_size_in_storage_elements insufficient Vratislav Podzimek
2016-10-18 12:35 ` Dmitry A. Kazakov
2016-10-18 15:26   ` Vratislav Podzimek
2016-10-18 16:03     ` Dmitry A. Kazakov
2016-10-19  1:39       ` Luke A. Guest
2016-10-19  7:33         ` Dmitry A. Kazakov
2016-10-20  0:59         ` Randy Brukardt [this message]
2016-10-19 15:45     ` Eryndlia Mavourneen
2016-10-19 15:53     ` Eryndlia Mavourneen
2016-10-19 13:34 ` Egil H H
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox