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=-1.9 required=3.0 tests=BAYES_00,T_SCC_BODY_TEXT_LINE, XPRIO autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: "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 Message-ID: References: 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 Xref: reader02.eternal-september.org comp.lang.ada:63893 List-Id: 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" 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