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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,80cee3866ad1db7b X-Google-Attributes: gid103376,public From: bobduff@world.std.com (Robert A Duff) Subject: Re: Dangling pointer? Date: 1996/04/16 Message-ID: #1/1 X-Deja-AN: 147841383 references: <4l0r36$jte@dewey.csun.edu> organization: The World Public Access UNIX, Brookline, MA newsgroups: comp.lang.ada Date: 1996-04-16T00:00:00+00:00 List-Id: In article <4l0r36$jte@dewey.csun.edu>, chen 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