comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Null Range in Unconstrasined Array
Date: Tue, 01 Sep 2009 11:34:30 -0400
Date: 2009-09-01T11:34:30-04:00	[thread overview]
Message-ID: <wcc4ormhe61.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: 76a9c14b-c573-4fd4-bbd8-7ab3bd078d79@j9g2000prh.googlegroups.com

Adam Beneschan <adam@irvine.com> writes:

> On Aug 31, 6:28�pm, Rick <rickdu...@gmail.com> wrote:
>> If I have an unconstrained array type 'My_Array_Type' and declare an
>> instance of it as:
>>
>> My_Array : My_Array_Type (1 .. 0);
>>
>> then the LRM tells me it is a null range:
>>
>> 3.5 (4): A range with lower bound L and upper bound R is described by
>> �L .. R�. If R is less than L, then the range is a null range, and
>> specifies an empty set of values.
>>
>> What, exactly, is My_Array (forgive the language) pointing to?

Well, arrays don't "point".

>> Is any memory allocated to My_Array?
>
> Most likely, no.  Randy gave a reason why a compiler might want to
> allocate a little bit of space for the array; but even if it does,
> it's memory that will never be used.

Randy's reason applies only if the array is aliased,
which the above one is not.  There's no reason the compiler 
has to allocate any space for My_Array above.

If we have:

    My_Array : My_Array_Type (1 .. 0);
    X : Boolean;

it is entirely possible (likely even) that My_Array'Address = X'Address.
Randy's concern about access values does not apply to addresses.

Usually, empty arrays are not statically known to be empty,
though.  In that case, some space might be used to store
the bounds.

>...Any attempt to refer to My_Array
> (X), no matter what X is, will raise Constraint_Error.

Right.

- Bob



  reply	other threads:[~2009-09-01 15:34 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-01  1:28 Null Range in Unconstrasined Array Rick
2009-09-01  3:11 ` Randy Brukardt
2009-09-01 14:50 ` Adam Beneschan
2009-09-01 15:34   ` Robert A Duff [this message]
2009-09-06 12:11     ` Peter C. Chapin
2009-09-06 12:41       ` Robert A Duff
2009-09-08 17:54         ` Adam Beneschan
2009-09-09  8:35           ` Stephen Leake
2009-09-09 13:00             ` Robert A Duff
2009-09-09 19:22             ` sjw
2009-09-10 23:24               ` Stephen Leake
replies disabled

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