Path: 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: <2619@yunexus.UUCP> <388@celit.UUCP> <118@psitech.UUCP> Reply-To: tarvaine@tukki.jyu.fi (Tapani Tarvainen) Organization: University of Jyvaskyla, Finland Lines: 17 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)