"do ... while ((NULL + 1) - 1);" -- valid C?
Robert A. Earl
rae98 at wash08.UUCP
Thu Aug 10 23:27:17 AEST 1989
In article <696 at ftp.COM> wjr at ftp.UUCP (Bill Rust) writes:
>In article <10684 at smoke.BRL.MIL> gwyn at brl.arpa (Doug Gwyn) writes:
>>In article <961 at virtech.UUCP> cpcahil at virtech.UUCP (Conor P. Cahill) writes:
>>>NULL + 1 is a valid operations, ...
>>No!
>In my experience, NULL is always defined using the preprocessor line
>"#define NULL 0" (or 0L). Since the while construct is relying on the
>fact NULL is, in fact, 0, doing NULL + 1 - 1 is ok.
>Bill Rust (wjr at ftp.com)
I have to disagree with Bill here. The NULL being
returned was from a string manipulation function...ie
not just a NULL but a (char *) NULL....I believe it is
illegal (or at least unportable) to add (char *)NULL + 1.
--
===========================================================
Name: Bob Earl Phone: (202) 872-6018 (wk)
UUCP: ...!uunet!wash08!rae98
BITNET: ...rae98 at CAS (At least, that is what I'm told)
More information about the Comp.lang.c
mailing list