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,5697899e4423465c X-Google-Attributes: gid103376,public From: Keith Thompson Subject: Re: null pointer representation (was: Boolean Representation) Date: 1998/09/27 Message-ID: #1/1 X-Deja-AN: 395386749 Cache-Post-Path: wagasa.cts.com!kst@king.cts.com References: Organization: CTS Network Services Newsgroups: comp.lang.ada Date: 1998-09-27T00:00:00+00:00 List-Id: evans@evans.pgh.pa.us (Arthur Evans Jr) writes: > In article , > Keith Thompson 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 <*> Qualcomm, San Diego, California, USA It takes a Viking to raze a village.