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: 103376,25ab365b646cef74 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news1.google.com!postnews.google.com!k36g2000pri.googlegroups.com!not-for-mail From: Jerry Newsgroups: comp.lang.ada Subject: Re: GNAT 4.2.3 Ubuntu reports weird compile error wrt Unchecked_Access Date: Sun, 17 Aug 2008 13:58:46 -0700 (PDT) Organization: http://groups.google.com Message-ID: <6da9fda5-22c5-48de-b424-f0df22109bfd@k36g2000pri.googlegroups.com> References: <7053ea09-38cd-4e30-9827-a1384bafd190@p31g2000prf.googlegroups.com> <37Ppk.5180$Mh5.1917@bgtnsc04-news.ops.worldnet.att.net> NNTP-Posting-Host: 75.171.118.139 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1219006726 5779 127.0.0.1 (17 Aug 2008 20:58:46 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 17 Aug 2008 20:58:46 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: k36g2000pri.googlegroups.com; posting-host=75.171.118.139; posting-account=x5rpZwoAAABMN2XPwcebPWPkebpwQNJG User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US) AppleWebKit/525.18 (KHTML, like Gecko, Safari/525.20) OmniWeb/v622.1.0.104087,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:1640 Date: 2008-08-17T13:58:46-07:00 List-Id: Thank you for your comments, but they don't exactly apply to my question. The code snippet that I gave, though brief, shows the use of 'Unchecked_Access. I used it precisely to overcome the accessibility rules ("Access-Type Lifetime Rule" in the terminology of Cohen, "Ada as a Second Langugage"). As I understand it, the compiler should not have issued the error that it did, and in fact on two of the compilers mentioned in my original post, it did not issue the error. The error should only be issued, in this case, when 'Access is used, and in fact, it is issued. The compiler in question seems to have issued a spurious error message. Jerry On Aug 16, 10:59=A0pm, a...@anon.org (anon) wrote: > If the GNAT compiler follows the RM on "accessibility" rules. =A0Then it > will force you to use the "Unchecked_Access" attribute for any non-local > pointer trying to point to local object". =A0Solution: If possible move t= he > object to be access to a package global variable (non-local), then you ca= n > use Access attribute. > > Note: > RM 13.10 (1) =3D> "The attribute Unchecked_Access is used to create acces= s > values in an unsafe manner -- the programmer is responsible for > preventing 'dangling references.' " > > In <7053ea09-38cd-4e30-9827-a1384bafd...@p31g2000prf.googlegroups.com>, J= erry writes: > > >I have a curious report from two members of the development team for > >PLplot, a popular plotting package for which I have written bindings > >in Ada. The project is mature enough that the team decided to enable > >Ada by default when building, so I am concerned about the following e- > >mail. > > >=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D begin e-mail =3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > > > > > >This latest change to the Ada bindings causes a build error for me > >with gnat 4.2.3 on Ubuntu. > > >plplot.adb:2751:37: non-local pointer cannot point to local object > >The offending line is > > =A0 =A0PL_Pen_Labels(Index) :=3D Temp_C_String'Unchecked_Access; > > > > > >This must depend on the version of gnat since I don't see this error > >for gnat 4.3.1-2 from Debian testing (and I presume Jerry didn't see > >it for his gnat-4.3 version as well). > > >=3D=3D=3D=3D=3D=3D=3D=3D=3D end e-mail =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > > >I (Jerry) in fact did not see a problem on my OS X 4.3 compiler. > > >I could supply more details of the code and might even try to write a > >small program but testing on someone else's machine would be a bit > >tedious. BUT--this error makes no sense to me--I would expect to (and > >_do_) see this error if the line in question is > > > =A0 =A0PL_Pen_Labels(Index) :=3D Temp_C_String'Access; > > >The whole purpose of using Unchecked_Access is to make this error go > >away. It this a known problem on 4.2.3 Unbutu? Is it a compiler error? > >Why does it work as expected on my 4.3 OS X, on 4.3.1-2 Debian > >testing, but not 4.2.3 Ubuntu? > > >Jerry