comp.lang.ada
 help / color / mirror / Atom feed
From: bobduff@world.std.com (Robert A Duff)
Subject: Re: Dangling pointer?
Date: 1996/04/16
Date: 1996-04-16T00:00:00+00:00	[thread overview]
Message-ID: <Dpz2BK.L4y@world.std.com> (raw)
In-Reply-To: 4l0r36$jte@dewey.csun.edu

In article <4l0r36$jte@dewey.csun.edu>, chen <kc44097@csun.edu> wrote:
>
>    What is "dangling pointer",can someone give me a defination and example?
>Please e-mail me kc44097@huey.csun.edu

A dangling pointer is a pointer that points to something that no longer
exists, or is invalid in some way.  For example:

    X: Some_Pointer := new Whatever;
    Y: Some_Pointer := X;
    ...
    Free(Y);
    ... -- Now, X is a dangling pointer, and you better not say X.all.

You can also create dangling pointers by using the 'Unchecked_Access
attribute to create a pointer to a local variable, and save that pointer
in a global.  When the procedure is left, the global contains a dangling
pointer.

In general, in Ada, dereferencing dangling errors is not detected -- you
won't usually get a sensible error message, but your program may go
haywire.

According to the RM, it's not a bug to create dangling pointers.  It's a
bug to deference them.

- Bob




  reply	other threads:[~1996-04-16  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-04-16  0:00 Dangling pointer? chen
1996-04-16  0:00 ` Robert A Duff [this message]
1996-04-19  0:00 ` Todd Coniam
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox