From: DJ Delorie <dj@delorie.com>
Subject: Re: some unusual errors
22 Sep 1998 16:13:54 -0400
Message-ID: <36080502.41C6@delorie.com>
References: <9809211418.AA12875@vviuh221.vvi.com> <199809212009.NAA00026.cygnus.gnu-win32@aleph.ssd.hal.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailer: Mozilla 3.0 (X11; I; IRIX 5.3 IP22)

J. J. Farrell wrote:
> isspace() is prototyped as isspace(int); if the caller
> were using the function version, then the prototype would
> be effective, and the char would have been silently and
> correctly widened to an int.

No, the char would have been silently and INcorrectly
widened to a *signed* int, resulting in a range of values of
-128..127.  That is not the legal range of values for the
is*() functions.

The legal range of values for is*() is 0..255 and EOF.  The
automatic widening of a [default signed] char results in
signed int values in the range -128..127.  You cannot rely
on the automatic widening to give correct results.

On a side note, using a signed char as the input makes it
impossible to tell the difference between character 255 and
the traditional EOF value of -1, as both have the same bit
pattern (0xff) when stored in a signed char variable.

Because there are 257 legal parameter values for is*(), an
8-bit variable is simply too small to represent them without
loss or inaccuracy.
