Path: utzoo!utgpu!watmath!att!tut.cis.ohio-state.edu!mailrus!ukma!husc6!spdcc!ftp!wjr
From: wjr@ftp.COM (Bill Rust)
Newsgroups: comp.lang.c
Subject: Re: "do ... while ((NULL + 1) - 1);" -- valid C?
Message-ID: <696@ftp.COM>
Date: 9 Aug 89 13:38:08 GMT
References: <1043@levels.sait.edu.au> <961@virtech.UUCP> <10684@smoke.BRL.MIL>
Reply-To: wjr@ftp.UUCP (Bill Rust)
Organization: FTP Software, Inc.
Lines: 15

In article <10684@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn) writes:
>In article <961@virtech.UUCP> cpcahil@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. I certainly wouldn't
recommend using it as a reference to memory. But, unless NULL is a 
reserved word to your compiler, the compiler sees 0 + 1 - 1 and that is
ok.

Bill Rust (wjr@ftp.com)