From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,5d624451bcaff335 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!newsfeed2.dallas1.level3.net!news.level3.com!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Null Range in Unconstrasined Array Date: Sun, 06 Sep 2009 08:41:22 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <76a9c14b-c573-4fd4-bbd8-7ab3bd078d79@j9g2000prh.googlegroups.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls6.std.com 1252240882 11284 192.74.137.71 (6 Sep 2009 12:41:22 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Sun, 6 Sep 2009 12:41:22 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:NxcwscRiwLkJs1FxNWc/etxQiHE= Xref: g2news2.google.com comp.lang.ada:8194 Date: 2009-09-06T08:41:22-04:00 List-Id: "Peter C. Chapin" writes: > Robert A Duff wrote in > news:wcc4ormhe61.fsf@shell01.TheWorld.com: > >> 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. > > > Wouldn't it be possible to pass My_Array to a subprogram expecting > My_Array_Type? Yes. >...The subprogram might consult the bounds on the formal > parameter before trying to use the array so sending a null array to such a > subprogram is not automatically going to cause a problem. In that case, it > seems like My_Array needs to have memory allocated for it to hold > information about the bounds. The called procedure has to have some way to know the bounds. That's true whether the bounds are 1..0 or 1..100. There are several ways to implement that. For example, the procedure could be passed the bounds as separate parameters, in two registers. I don't consider that to be "memory allocated for My_Array", because it is not allocated when the compiler sees My_Array -- it is allocated when the compiler sees a call (and separately for each call). In this case, My_Array'Address = X'Address is likely. Alternatively, the compiler could allocate the bounds as part of My_Array, just in case there are some such calls. In this case, My_Array'Address = X'Address is unlikely. If the procedure is inlined, the bounds might end up being stored only in the immediate-value fields of instructions. Or the entire procedure call might vanish, because the compiler knows it's (say) looping through an empty array. - Bob