Two different approaches to the implementation of integral
promotion rules have been taken by earlier versions of C. The
first approach is called unsigned preserving, in which
unsigned char
and unsigned short
widen
to unsigned int
. The second approach is called
value preserving, in which unsigned char
and
unsigned short
widen to signed int
if the
value can be represented; otherwise they widen to unsigned
int
. The Standard specifies that integral promotions are to
be value-preserving. This approach is followed in all modes except
common C and VAX C mode, and results in a quiet change to programs
depending on unsigned-preserving arithmetic conversions.
To aid the programmer in locating arithmetic conversions that
depend on unsigned-preserving rules, any integral promotions of
unsigned char
and unsigned short
to
int
that could be affected by the value-preserving
approach for integral promotions are flagged with the error-checking
option.