Promotion of integral types
Tom Kelly
tom at hcrvx1.UUCP
Fri Sep 26 22:23:39 AEST 1986
In article <271 at myrias.UUCP> cmt at myrias.UUCP (Chris Thomson) writes:
> ... 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.
This change was the subject of long and hard investigation and
debate in the ANSI C (X3J11) committee. It is a quiet change
from common practice in (for example) PCC-based compilers, but
there are other implementations that do promote unsigned
char and unsigned short to int. The decision was not made lightly -
the debate went on for at least a year.
The issue is discussed at length in the Rationale (86-099 7 July 1986),
in 3.2 Conversions (pp. 32-33). In particular, on p 33:
QUIET CHANGE
A program that depends upon unsigned preserving arithmetic
conversions will behave differently, probably without
complaint. This is considered the most serious semantic
change made by the Committee to a widespread current
practice.
Tom Kelly (416) 922-1937
Human Computing Resources Corp.
{utzoo, ihnp4, decvax}!hcr!hcrvx1!tom
More information about the Comp.lang.c
mailing list