Promotion of integral types

Brett Galloway brett at wjvax.UUCP
Sat Sep 27 05:19:45 AEST 1986


In article <271 at myrias.UUCP> cmt at myrias.UUCP (Chris Thomson) writes:
>In article <3422 at umcp-cs.UUCP> Chris Torek writes:
>
>> 	Storage Type		Expression Equivalent
>> 	------------		---------------------
>> 	char			int
>> 	unsigned char		unsigned int
>> 	short			int
>> 	unsigned short		unsigned int
>> 	int			int
>> [more types]
>It is interesting to note that K&R does not say that unsigned char or
>unsigned short get promoted to unsigned int; it says that they get promoted
>to integer (on page 183), which is a bit vague.  Harbison & Steele says
>very clearly what is said above.  The ANSI Draft (1986.07.09 version) says
>very clearly that unsigned char and unsigned short are promoted to int,
>since the values can all be represented in an int (assuming sizeof(int)
>is greater than sizeof(short), which is usually true).
>
>What to do?  Frankly, I prefer the ANSI approach, but it does represent a
>silent change from what H&S (and Chris Torek) perceive to be standard
>practice.  For some reason, it is not flagged as such in the rationale
>document; it isn't even discussed there.

I disagree.  One cannot assume that sizeof(int) > sizeof(short).
-- 
-------------
Brett Galloway
{pesnta,twg,ios,qubix,turtlevax,tymix,vecpyr,certes,isi}!wjvax!brett



More information about the Comp.lang.c mailing list