Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uunet!virtech!cpcahil From: cpcahil@virtech.uucp (Conor P. Cahill) Newsgroups: comp.unix.wizards Subject: Re: What machines core dump on deref of NULL? Message-ID: <1990Jun29.232656.20695@virtech.uucp> Date: 29 Jun 90 23:26:56 GMT References: <444@mtndew.UUCP> <31079@cup.portal.com> <13226@smoke.BRL.MIL> <412@minya.UUCP> Reply-To: cpcahil@virtech.UUCP (Conor P. Cahill) Organization: Virtual Technologies Inc., Sterling VA Lines: 29 In article <412@minya.UUCP> jc@minya.UUCP (John Chambers) writes: >Hey, wait just a minute here. I can't let such an erroneous error go >unchallenged! Dereferencing a null pointer is quite definitely *not* >an error, bug, mistake, or any other pejorative, in a great many sorts >of applications. > >The trouble with generalizing to all C code is that C outgrew Unix >about a decade ago. HOWEVER, this is not comp.lang.c. This comp.unix.whatever and in this context dereferencing a null pointer is, or should be, a no-no. Any unix code that does, has at least 1 serious bug that should be fixed. I remember one time when I was porting some code to a sun 3 and ran across the following line of code: if( strcmp(variable,(char*)0) == 0 ) I really wasn't sure what the original programmer was attempting to check (since the first byte at 0 was a null byte on the original machine), so I changed the code to be: if( (variable == (char *)0) || (*variable == '\0')) -- Conor P. Cahill (703)430-9247 Virtual Technologies, Inc., uunet!virtech!cpcahil 46030 Manekin Plaza, Suite 160 Sterling, VA 22170