🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #390

Re: (char *)(-1)

#390
From: david Fridley
Date: Fri, 28 Jul 1989 19:53
22 lines
1587 bytes
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.
Technical Details
Message-ID: <119@psitech.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!cs.utexas.edu!uunet!psitech!david
References: <GEOFF.89Jun11231924@onyx.cs.warwick.ac.uk> <2619@yunexus.UUCP> <1063@tukki.jyu.fi>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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: <GEOFF.89Jun11231924@onyx.cs.warwick.ac.uk> <2619@yunexus.UUCP> <1063@tukki.jyu.fi>
Organization: PsiTech Inc., Fountain Valley, CA
Lines: 22