Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

The good thing about standards is that there are so many to choose from. -- Andrew S. Tanenbaum


devel / comp.lang.ada / What is X'Address of an empty array?

SubjectAuthor
* What is X'Address of an empty array?Dmitry A. Kazakov
`* Re: What is X'Address of an empty array?Randy Brukardt
 `- Re: What is X'Address of an empty array?Dmitry A. Kazakov

1
What is X'Address of an empty array?

<t7514c$11tj$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!siG8trSPtxwtkBCOZpBn8A.user.46.165.242.91.POSTED!not-for-mail
From: mail...@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.ada
Subject: What is X'Address of an empty array?
Date: Tue, 31 May 2022 14:19:24 +0200
Organization: Aioe.org NNTP Server
Message-ID: <t7514c$11tj$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="34739"; posting-host="siG8trSPtxwtkBCOZpBn8A.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.9.1
Content-Language: en-US
X-Notice: Filtered by postfilter v. 0.9.2
 by: Dmitry A. Kazakov - Tue, 31 May 2022 12:19 UTC

I have a language lawyering question. According to ARM X'Address is the
address of the first array element. What is the address of empty array?

In the case of an array with bounds it could be the address following
the bounds.

But what about a definite empty array? Of zero length (and presumably
zero size). Would the compiler have to invent some address?

P.S. With GNAT:

type NUL is array (1..0) of Integer;
S : NUL;

S'Size is 8 and it has some address that holds the byte.

Talking about the dark matter in our Universe. This is what empty arrays
are constructed of! (:-))

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

Re: What is X'Address of an empty array?

<t761nn$daf$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ran...@rrsoftware.com (Randy Brukardt)
Newsgroups: comp.lang.ada
Subject: Re: What is X'Address of an empty array?
Date: Tue, 31 May 2022 16:35:49 -0500
Organization: A noiseless patient Spider
Lines: 56
Message-ID: <t761nn$daf$1@dont-email.me>
References: <t7514c$11tj$1@gioia.aioe.org>
Injection-Date: Tue, 31 May 2022 21:35:51 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="96583cc4810bb76e2a1cfee9559d34d8";
logging-data="13647"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+gZjVWo3Yjx2lTZ0JREuqhn5CnsBwMh5o="
Cancel-Lock: sha1:friNqH1PihKqqsnmrHsMOapu3Ic=
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246
X-RFC2646: Format=Flowed; Response
X-Newsreader: Microsoft Outlook Express 6.00.2900.5931
X-Priority: 3
X-MSMail-Priority: Normal
 by: Randy Brukardt - Tue, 31 May 2022 21:35 UTC

Aliased objects should never have zero-size in Ada (or, at least, ever be
allocated at the same address). I believe that is because of the required
result of the equality operator. Specifically:

type NUL is array (1..0) of Integer;
A, B : aliased NUL;
type PNul is access Nul;
PA : PNul := A'Access; PB : PNul := B'Access;

if PA = PB then
Report.Failed ("Access to two distinct objects can not be equal");
end if;

If an object is not aliased, it is undefined whether 'Address will work
reliably with it (it probably does in GNAT, it might not in Janus/Ada, etc.)
If the objects ARE aliased, then 'Address works essentially the same as
'Access.

I personally find this a bit of overspecification in Ada, but since
zero-size objects are unusual, no one has thought it worth going through the
effort to change. (And of course such a change would complicate static
analysis.) We (the ARG) did discuss this topic at one point (I don't have
the AI number at hand).

Randy.

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message
news:t7514c$11tj$1@gioia.aioe.org...
>I have a language lawyering question. According to ARM X'Address is the
>address of the first array element. What is the address of empty array?
>
> In the case of an array with bounds it could be the address following the
> bounds.
>
> But what about a definite empty array? Of zero length (and presumably zero
> size). Would the compiler have to invent some address?
>
> P.S. With GNAT:
>
> type NUL is array (1..0) of Integer;
> S : NUL;
>
> S'Size is 8 and it has some address that holds the byte.
>
> Talking about the dark matter in our Universe. This is what empty arrays
> are constructed of! (:-))
>
> --
> Regards,
> Dmitry A. Kazakov
> http://www.dmitry-kazakov.de

Re: What is X'Address of an empty array?

<t77n8k$1jan$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!siG8trSPtxwtkBCOZpBn8A.user.46.165.242.91.POSTED!not-for-mail
From: mail...@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.ada
Subject: Re: What is X'Address of an empty array?
Date: Wed, 1 Jun 2022 14:49:25 +0200
Organization: Aioe.org NNTP Server
Message-ID: <t77n8k$1jan$1@gioia.aioe.org>
References: <t7514c$11tj$1@gioia.aioe.org> <t761nn$daf$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="52567"; posting-host="siG8trSPtxwtkBCOZpBn8A.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.9.1
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-US
 by: Dmitry A. Kazakov - Wed, 1 Jun 2022 12:49 UTC

On 2022-05-31 23:35, Randy Brukardt wrote:
> Aliased objects should never have zero-size in Ada (or, at least, ever be
> allocated at the same address). I believe that is because of the required
> result of the equality operator. Specifically:
>
> type NUL is array (1..0) of Integer;
> A, B : aliased NUL;
> type PNul is access Nul;
> PA : PNul := A'Access; PB : PNul := B'Access;
>
> if PA = PB then
> Report.Failed ("Access to two distinct objects can not be equal");
> end if;
>
> If an object is not aliased, it is undefined whether 'Address will work
> reliably with it (it probably does in GNAT, it might not in Janus/Ada, etc.)
> If the objects ARE aliased, then 'Address works essentially the same as
> 'Access.
>
> I personally find this a bit of overspecification in Ada, but since
> zero-size objects are unusual, no one has thought it worth going through the
> effort to change. (And of course such a change would complicate static
> analysis.) We (the ARG) did discuss this topic at one point (I don't have
> the AI number at hand).

It is actually rather nice.

I recently stumbled upon code:

A (A'First)'Address

in C bindings, when the other side has something like:

const double * a, int len

It of course fails in the marginal case when the array is empty. But
A'Address seems never do.

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor