From: Jeffrey Carter <spam@spam.com>
Subject: Re: Ptr Problem Question
Date: Fri, 01 Oct 2004 18:12:02 GMT
Date: 2004-10-01T18:12:02+00:00 [thread overview]
Message-ID: <S5h7d.425$M05.110@newsread3.news.pas.earthlink.net> (raw)
In-Reply-To: <6Aa7d.465487$OB3.325741@bgtnsc05-news.ops.worldnet.att.net>
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
prev parent reply other threads:[~2004-10-01 18:12 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-10-01 10:29 gnat 3.15p with kernel 2.6 / SuSE 9.1 Thomas Aho
2004-10-01 10:40 ` Florian Weimer
2004-10-01 13:24 ` Marc A. Criley
2004-10-01 17:15 ` Ludovic Brenta
2004-10-04 8:36 ` Alex R. Mosteo
2004-10-05 6:35 ` Thomas Aho
2004-10-01 10:46 ` Ptr Problem Question Arthur Schwarz
2004-10-01 11:04 ` Marius Amado Alves
2004-10-01 18:12 ` Jeffrey Carter [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox