(char *)(-1)

Tapani Tarvainen tarvaine at tukki.jyu.fi
Fri Jul 28 13:43:24 AEST 1989


In article <118 at psitech.UUCP> david at 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 at jyu.fi, tarvainen at finjyu.bitnet)



More information about the Comp.std.c mailing list