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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8a402d78988bdf2b X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-12-21 16:50:42 PST Path: archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!news-out.visi.com!petbe.visi.com!in.100proofnews.com!in.100proofnews.com!cycny01.gnilink.net!cyclone1.gnilink.net!small1.nntp.aus1.giganews.com!nntp2.aus1.giganews.com!intern1.nntp.aus1.giganews.com!nntp.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail NNTP-Posting-Date: Sun, 21 Dec 2003 18:50:40 -0600 Date: Sun, 21 Dec 2003 19:50:38 -0500 From: "Robert I. Eachus" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: [announcement] SYSAPI and SYSSVC for Windows References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 24.34.214.193 X-Trace: sv3-UPKHvEuhKZJzj6Q+6HuU87MNZYekQOt+XXIKYXTn4hv2cZcM+XeUaRXcbhdWilkw+olzzf+CLp/hxaa!jg/0QfmTGiDpDPuZblprTCqqsw3N5w1Tz/rfPaa3JyvrcVtGQcF+IjNDVKHXtg== X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.1 Xref: archiver1.google.com comp.lang.ada:3681 Date: 2003-12-21T19:50:38-05:00 List-Id: Ekkehard Morgenstern wrote: > "Michal Morawski" wrote: > >>Try: >> O.B := O.A(1)'Unchecked_Access; -- This is OK, A(i) are aliased >>'Access does not work because in the procedure You are getting address of >>the variable (may be) on the stack > > > Yup, unchecked access works (compiles). > > thanks! :) This is exactly the sort of thing that Unchecked_Access is provided for. You can tell that wherever you can see O.B, O.A must also exist. (Even though those names may be long gone.) At first though, I thought that there was a bug here. There is nothing wrong in general with the assignment. The reason for the error had to do with accessibility levels of parameters. If O is not a parameter: procedure ttest2 is type Integer_Array is array (Integer range <>) of aliased Integer; type Integer_Access is access all Integer; type T is limited record A : Integer_Array (1..3); B : Integer_Access; end record; O : T; procedure F is begin O.B := O.A(1)'Access; -- This is OK, A(i) are aliased end; begin F; end ttest2; gnatmake ttest2 gcc -c ttest2.adb gnatbind -x ttest2.ali gnatlink ttest2.ali Everything is fine in this case, since the static accessibility levels match. As for the original ttest0, at first I thought it should be legal, but there would be a run-time check that could raise Program_Error. (The problem is incidently is not the assignment of the access value to O.B, it is taking O.A(1)'Access.) RM 3.10.2(29) says: "A check is made that the accessibility level of X is not deeper than that of the access type A. If this check fails, Program_Error is raised." But there is also paragraph RM 3.10.2(28): "The accessibility level of the view shall not be statically deeper than that of the access type A..." The static accessability level of the VIEW O.A(1) is that of F: 3.10.2(7): "A parameter of a master has the same accessibility level as the master." So for the first example, there is a legality check, and it is independent of the accessiblity level of the object actually passed as a parameter to F. Aren't you glad that 'Unchecked_Access exists for cases like this, where you can figure that the access value is safe, even if the compiler can't? Or where it is harder to figure out if the compiler will allow it than to prove it safe? -- Robert I. Eachus "The war on terror is a different kind of war, waged capture by capture, cell by cell, and victory by victory. Our security is assured by our perseverance and by our sure belief in the success of liberty." -- George W. Bush