Undefined behavior in 950605-1.c

Andreas Schwab schwab@suse.de
Thu Jul 25 11:24:00 GMT 2002


Momchil Velikov <velco@fadata.bg> writes:

|> >>>>> "Alan" == Alan Modra <amodra@bigpond.net.au> writes:
|> 
|> Alan> On Thu, Jul 25, 2002 at 12:53:59PM +0300, Momchil Velikov wrote:
|> >> representable if the promoted type of the parametar is unsigned.
|> 
|> Alan> Ah, but what is the promoted type of "unsigned char"?  int!
|> 
|> ISO/IEC 9899:1999 6.5.2.2 [#6]
|> 
|>   " ... the other promoted type is the corresponding unsigned integer
|>   type, ..."
|> 
|> IMHO, that means that it is legal for the promoted type of ``unsigned
|> char'' to be ``unsigned int''.

Only if UCHAR_MAX == UINT_MAX.  Otherwise int can represent all values of
unsigned char, thus unsigned char is promoted to int.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."



More information about the Gcc mailing list