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,f19adc1c782ed4a3 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!newsfeed.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread3.news.pas.earthlink.net.POSTED!a6202946!not-for-mail From: Jeffrey Carter Organization: jrcarter commercial-at acm [period | full stop] org User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Ptr Problem Question References: <6Aa7d.465487$OB3.325741@bgtnsc05-news.ops.worldnet.att.net> In-Reply-To: <6Aa7d.465487$OB3.325741@bgtnsc05-news.ops.worldnet.att.net> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Fri, 01 Oct 2004 18:12:02 GMT NNTP-Posting-Host: 63.184.9.112 X-Complaints-To: abuse@earthlink.net X-Trace: newsread3.news.pas.earthlink.net 1096654322 63.184.9.112 (Fri, 01 Oct 2004 11:12:02 PDT) NNTP-Posting-Date: Fri, 01 Oct 2004 11:12:02 PDT Xref: g2news1.google.com comp.lang.ada:4524 Date: 2004-10-01T18:12:02+00:00 List-Id: Arthur Schwarz wrote: > Each Ptr assignment below yields the following error message: > > -- 9. Ptr : a.X_Ptr := Object'Access; > -- >>> non-local pointer cannot point to local object A.X_Ptr is declared at the library level. This means that you could assign Ptr to a variable declared at the library level, and it would exist after the subprogram returns, leaving a dangling reference. Ada's accessibility rules prevent this. If you're sure this won't happen, you can use 'Unchecked_Access instead. You are then responsible for making sure you don't leave any dangling refererences; the compiler can't help you. A better question, though, is why you are using pointers. Unless you're building a dynamic data structure, pointers are rarely needed in Ada. -- Jeff Carter "You cheesy lot of second-hand electric donkey-bottom biters." Monty Python & the Holy Grail 14