Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
From: lwm@bronze.ucs.indiana.edu (Larry Meehan)
Subject: Re: strcat(foo,NULL) core dumps on Ultrix
Date: 12 Jun 91 21:41:24 GMT	[thread overview]
Message-ID: <1991Jun12.214124.24990@bronze.ucs.indiana.edu> (raw)
In-Reply-To: 1991Jun12.062045.13467@tkou02.enet.dec.com

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)


  reply	other threads:[~1991-06-12 21:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1991-06-11 12:34 strcat(foo,NULL) core dumps on Ultrix Rob Gabbard
1991-06-12  4:00 ` Larry Meehan
1991-06-12  6:20   ` Norman Diamond
1991-06-12 21:41     ` Larry Meehan [this message]
1991-06-13  7:20       ` Norman Diamond
1991-06-12  4:12 ` Norman Diamond
1991-06-12  4:34 ` George Robbins
1991-06-12 17:05 ` Lance Franklin
read-only archive

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