Undefined behavior in 950605-1.c

Momchil Velikov velco@fadata.bg
Thu Jul 25 10:56:00 GMT 2002


>>>>> "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''.  Isn't that the case with architectures
with a definition of PROMOTE_MODE, which does not change UNSIGNEDP or
sets it to 1, e.g, ARM, PPC, V850 ?

Indeed it contradicts with 6.3.1.1 [#2]:

  "If an int can represent all values of the original type, the value
  is converted to an int; otherwise, it is converted to an unsigned
  int.  These are called the integer promotions."

~velco



More information about the Gcc mailing list