Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!bronze!lwm From: lwm@bronze.ucs.indiana.edu (Larry Meehan) Newsgroups: comp.sys.dec Subject: Re: strcat(foo,NULL) core dumps on Ultrix Keywords: null NULL Message-ID: <1991Jun12.214124.24990@bronze.ucs.indiana.edu> Date: 12 Jun 91 21:41:24 GMT References: <966@sdrc.COM> <1991Jun12.040043.24091@bronze.ucs.indiana.edu> <1991Jun12.062045.13467@tkou02.enet.dec.com> Organization: Indiana University Lines: 42 In article <1991Jun12.040043.24091@bronze.ucs.indiana.edu> lwm@bronze.ucs.indiana.edu (Larry Meehan) writes: >which is legal on a VAX, What I meant was that it results in a legal memory reference. In <1991Jun12.062045.13467@tkou02.enet.dec.com> diamond@jit533.swstokyo.dec.com (Norman Diamond) writes: >When a source program uses an integer constant 0 as a pointer, the compiler >must recognize it as a null pointer constant. However, a null pointer >constant does not have to be address 0 at execution time. If the source >program uses 0 for an integer, its binary value has to consist of 0-bits, >but for a null pointer it does not have to do so. I always knew that NULL could have a non-zero value, depending on implementation details, but I didn't realize it could be specified as 0 in the source and that the compiler would translate this to the "correct" value. I have always tried to avoid writing code that assumes anything about the value of NULL. I have always felt uneasy about constructs like while (*argv) and avoided them myself. It sounds from what you say like this is a very dangerous (non-portable) line of code. I mean, is the compiler expected to translate this to while (*argv != NULL) on systems that have a non-zero value for NULL? I realize this newsgroup is not about C programming, but this issue will probably continue to bite DEC customers who move from VAX to RISC, so it is probably good for it to appear here once in a while. -- Larry Meehan University Computing Services lwm@ucs.indiana.edu Indiana University ("Industry without art is brutality." -- Ananda Coomaraswamy) -- Larry Meehan University Computing Services lwm@ucs.indiana.edu Indiana University ("Industry without art is brutality." -- Ananda Coomaraswamy)