comp.lang.ada
 help / color / mirror / Atom feed
From: Keith Thompson <kst@king.cts.com>
Subject: Re: null pointer representation (was: Boolean Representation)
Date: 1998/09/27
Date: 1998-09-27T00:00:00+00:00	[thread overview]
Message-ID: <yec3e9dqs5f.fsf@king.cts.com> (raw)
In-Reply-To: evans-2709981430360001@ppp23.s9.pgh.net

evans@evans.pgh.pa.us (Arthur Evans Jr) writes:
> In article <yec1zoyd2xa.fsf@king.cts.com>,
> Keith Thompson <kst@king.cts.com> wrote:
> 
> > Nor can we assume that a ... null pointer is represented as all-bits-zero
> 
> Indeed not.  Some years ago I was concerned about this very issue and
> asked around (probably on cla) about it.  The answers were instructive.
> Most compilers did in fact use all zeros, but some other values were
> used, including one compiler (from IBM, I think) that used the HEX
> number DEAD BEEF.  I suppose it really stood out in HEX dumps.
> 
> Since I was interfacing to C-code in Ada-83 and code on the C side
> needed zero for null pointers, I ended up writing some extra code to
> ensure that value, even though the implementation I was then using
> represented the null pointer as zero.

Incidentally (and only slightly off-topic), C also does not guarantee
that a null pointer is represented as all-bits-zero.  There's enough C
code out there that assumes that it is that almost all C compilers use
the "expected" representation, but there's no such requirement.  (The
issue is further confused by the fact that the source representation
of a C null pointer is an integer literal 0.)  See the comp.lang.c FAQ
for an extensive discussion of this.

Getting back to Ada, I was a little surprised to see that the generic
package Interfaces.C.Pointers doesn't explicitly declare a constant
corresponding to a C NULL pointer, but this should be covered by the
statement that the type Pointer is C-compatible.  So Ada 95
programmers shouldn't have to worry about it as long as they use the
interfacing features provided by the language.

-- 
Keith Thompson (The_Other_Keith) kst@cts.com <http://www.ghoti.net/~kst> <*>
Qualcomm, San Diego, California, USA  <http://www.qualcomm.com>
It takes a Viking to raze a village.




  reply	other threads:[~1998-09-27  0:00 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-09-24  0:00 Boolean Representation matthew_snyder
1998-09-24  0:00 ` dennison
1998-09-24  0:00   ` Keith Thompson
1998-09-25  0:00     ` dennison
1998-09-25  0:00       ` Keith Thompson
1998-09-26  0:00         ` Tucker Taft
1998-09-26  0:00           ` Keith Thompson
1998-09-27  0:00             ` dewarr
1998-09-27  0:00             ` null pointer representation (was: Boolean Representation) Arthur Evans Jr
1998-09-27  0:00               ` Keith Thompson [this message]
1998-09-28  0:00               ` dewarr
1998-09-28  0:00                 ` Lieven Marchand
1998-09-28  0:00                 ` Keith Thompson
1998-09-28  0:00                   ` dewarr
1998-09-30  0:00                     ` Keith Thompson
1998-10-02  0:00                       ` Robert I. Eachus
1998-09-27  0:00           ` Boolean Representation dewarr
1998-09-24  0:00 ` dewarr
1998-09-24  0:00   ` matthew_snyder
1998-09-24  0:00     ` Tom Moran
1998-09-25  0:00       ` dewarr
1998-09-25  0:00         ` Tom Moran
1998-09-24  0:00     ` dennison
1998-09-25  0:00     ` Robert I. Eachus
1998-09-25  0:00     ` dewarr
1998-09-24  0:00   ` Samuel T. Harris
1998-09-25  0:00     ` dewarr
1998-09-27  0:00       ` Samuel T. Harris
1998-09-28  0:00         ` dewar
replies disabled

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