comp.lang.ada
 help / color / mirror / Atom feed
* Access vs. Address ?
@ 1996-04-08  0:00 W. Wesley Groleau (Wes)
  1996-04-08  0:00 ` Robert Dewar
  0 siblings, 1 reply; 2+ messages in thread
From: W. Wesley Groleau (Wes) @ 1996-04-08  0:00 UTC (permalink / raw)


> It is surprising how MUCH Ada code out there relies on the assumption
> that all pointers are the same size as addresses. ...

This assumption is normally accompanied by a more dangerous assumption
that all pointers ARE addresses.  Even though this is usually true,
it IS NOT REQUIRED by either LRM.  And even when it is true, what is
happening is usually NOT what the programmer meant.  I refer to the
Unchecked_Conversion of an access value to an address when what is
wanted is the address of the accessed item.

begin -- Soapbox

   -- The address of  Pointer.all  is  Pointer.all'Address --

   -- it is NOT  Convert_To_Address (Pointer);

   -- The latter works SOMETIMES with SOME compilers.  And when it doesn't
   -- work, it can REALLY screw things up!

end Soapbox;

Feel free to share this with your beginning programmers  :-)

--
---------------------------------------------------------------------------
W. Wesley Groleau (Wes)                                Office: 219-429-4923
Magnavox - Mail Stop 10-40                               Home: 219-471-7206
Fort Wayne,  IN   46808              elm (Unix): wwgrol@pseserv3.fw.hac.com
---------------------------------------------------------------------------




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Access vs. Address ?
  1996-04-08  0:00 Access vs. Address ? W. Wesley Groleau (Wes)
@ 1996-04-08  0:00 ` Robert Dewar
  0 siblings, 0 replies; 2+ messages in thread
From: Robert Dewar @ 1996-04-08  0:00 UTC (permalink / raw)


Wes says

"   -- The address of  Pointer.all  is  Pointer.all'Address --"

and advises against use of unchecked_conversoin of pointers <-> addresses.

True enough. Even better advice in Ada 95 is always to use the
Address_To_Acces_Conversions package. Note that even with this
package, the conversion of an address to a pointer to unconstrained
array is VERY dubious (where do the bounds come from?)





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1996-04-08  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-04-08  0:00 Access vs. Address ? W. Wesley Groleau (Wes)
1996-04-08  0:00 ` Robert Dewar

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