Article View: comp.std.c
Article #4994Re: Is it legal to add 0 to NULL? What about NULL < NULL?
From: Mark Brader
Date: Mon, 08 Apr 1996 05:30
Date: Mon, 08 Apr 1996 05:30
19 lines
1173 bytes
1173 bytes
> > Thing *a = A;
> > Thing *fence = a + S;
> > for (; a < fence; ++a)
> > /* use a */;
> >
> > but in my case, if S happens to be 0, a will start out NULL.
Er, no. If S happens to be 0, but A yields a valid Thing * pointer,
then a and fence will both start out equal to that pointer value.
If A is a null pointer or null pointer constant, *then* a will start
out as a null pointer, and the undefined behavior described by Lawrence
Kirby in the Referenced article will occur.
--
Mark Brader, msb@sq.com, SoftQuad Inc., Toronto
"I'm a little worried about the bug-eater," she said. "We're embedded
in bugs, have you noticed?" -- Niven, "The Integral Trees"
My text in this article is in the public domain.
Technical Details
Message-ID:
<1996Apr8.053026.7583@sq.com>Path:
arc1-ca.pugleaf.net!news.uunet.ca!wildcan!sq!msbReferences:
<ff1d.smail.smayo@tiac.net> <828905693snz@genesis.demon.co.uk>Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c Path: arc1-ca.pugleaf.net!news.uunet.ca!wildcan!sq!msb From: msb@sq.com (Mark Brader) Subject: Re: Is it legal to add 0 to NULL? What about NULL < NULL? Message-ID: <1996Apr8.053026.7583@sq.com> Summary: No, but the wrong question was asked Organization: SoftQuad Inc., Toronto, Canada References: <ff1d.smail.smayo@tiac.net> <828905693snz@genesis.demon.co.uk> Date: Mon, 8 Apr 1996 05:30:26 GMT