Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!cs.utexas.edu!uunet!psitech!david From: david@psitech.UUCP (david Fridley) Newsgroups: comp.std.c Subject: Re: (char *)(-1) Summary: Sometimes NULL can look like a valid pointer. Keywords: pointers, casts Message-ID: <119@psitech.UUCP> Date: 28 Jul 89 19:53:41 GMT References: <2619@yunexus.UUCP> <1063@tukki.jyu.fi> Organization: PsiTech Inc., Fountain Valley, CA Lines: 22 In article <1063@tukki.jyu.fi>, tarvaine@tukki.jyu.fi (Tapani Tarvainen) writes: > In article <118@psitech.UUCP> david@psitech.UUCP (david Fridley) writes: > > If -1 isn't safe, is there any other value (besides NULL) that can > safely be returned from a (any *) function to indicate error? > -- > Tapani Tarvainen (tarvaine@jyu.fi, tarvainen@finjyu.bitnet) On some systems, even NULL can accidently be a valid pointer. The environment has to take precautions to prevent this, like starting virtual data sections at 100 instead of 0, etc. But since NULL is written in K&R and (-1) is not, it is not garanteed to be portable. I have not had any problems though, and it sure is convenient to be able to return more than one fail code from a function that returns a pointer. Does any body have an environment where they think this will not work? -- david. DISCLAIMER: If it's important have a backup. If it ain't broke don't fix it. Proceed at your own risk. My oponions are MY own. Spelling does not count. My fondest dream is to leave this planet.