🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #384

(char *)(-1)

#384
From: Tapani Tarvainen
Date: Fri, 28 Jul 1989 03:43
17 lines
1334 bytes
In article <118@psitech.UUCP> david@psitech.UUCP (david Fridley) writes:

>* OUTPUT:
>* a pointer to the next symbol on the input is returned.  This buffer has
>* been malloc()ed and should be free()ed when it is nolonger needed. if
>* NULL is returned there was an error getting the next string, if (-1) is
>* returned there were no more symbols.

Is it safe to return -1?
I mean, isn't it possible that (char *)(-1) is a valid pointer
in some system and could have been returned by malloc(), or does
the pANS require it isn't?

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)
Technical Details
Message-ID: <1063@tukki.jyu.fi>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!cs.utexas.edu!uunet!mcvax!kth!draken!tut!tukki!tarvaine
References: <GEOFF.89Jun11231924@onyx.cs.warwick.ac.uk> <2619@yunexus.UUCP> <388@celit.UUCP> <118@psitech.UUCP>

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!mcvax!kth!draken!tut!tukki!tarvaine
From: tarvaine@tukki.jyu.fi (Tapani Tarvainen)
Newsgroups: comp.std.c
Subject: (char *)(-1)
Summary: can (char *)(-1) look like a valid pointer?
Keywords: pointers, casts
Message-ID: <1063@tukki.jyu.fi>
Date: 28 Jul 89 03:43:24 GMT
References: <GEOFF.89Jun11231924@onyx.cs.warwick.ac.uk> <2619@yunexus.UUCP> <388@celit.UUCP> <118@psitech.UUCP>
Reply-To: tarvaine@tukki.jyu.fi (Tapani Tarvainen)
Organization: University of Jyvaskyla, Finland
Lines: 17