Public Comment Number PC-UK0280 ISO/IEC CD2 9899 (SC22N2794) Public Comment =========================================== Date: 1998-12-12 Author: C.D.W.Feather Author Affiliation: Self Postal Address: Demon Internet Ltd. 322 Regents Park Road London N3 2QQ United Kingdom E-mail Address: Telephone Number: +44 181 371 1138 Fax Number: +44 181 371 1037 Category: Feature that should be included Committee Draft subsection: 5.2.4.2.1 Title: Ensure int can hold all characters Detailed description: A number of functions in the standard library (particularly in and assume that an int is capable of holding every possible unsigned char value. If this is not the case then these functions will, to say the least, behave in a peculiar manner. There is far too much code that makes this assumption. For example, code like: int c; while ((c = getchar ()) == EOF) // ... an idiom which dates back to the original authors of C, will misbehave on such implementations. There is at least one value readable from a binary stream that will return EOF. For another example, code that calls ungetc() assumes that any character read will not equal EOF, since the function is defined to fail if an attempt is made to push back EOF. It is possible to work around these, and other, issues, but to do so requires a level of defensive coding that is not within the spirit of C. It is better to require that the type signed int be able to hold every value from 0 to UCHAR_MAX; EOF is, of course, negative and so outside this range. Note that all the relevant issues appear in library functions, so freestanding implementations are not affected by them. These are also the implementations that are likely to want to make unsigned char and unsigned int the same size. Append to 5.2.4.2.1p2: On a hosted implementation, INT_MAX shall be not less than UCHAR_MAX.