Public Comment Number PC-UK0014 ISO/IEC CD 9899 (SC22N2620) Public Comment =========================================== Date: 1997-12-29 Author: Clive D.W. Feather Author Affiliation: Self Postal Address: Demon Internet Limited 322 Regents Park Road London N3 2QQ United Kingdom E-mail Address: Telephone Number: +44 181 371 1138 Fax Number: +44 181 371 1037 Number of individual comments: 1 Comment 1. Category: Inconsistency Committee Draft subsection: 6.5.8 Title: problems with initializing unsigned char arrays. Detailed description: Consider the following declaration: unsigned char s [] = "\x80\xff"; The first element of the string literal has the value: (char) 128 and the second element has the value: (char) 255 If the type char is signed and CHAR_MAX is less than 128, these two expressions are implementation-defined. In particular, on a ones- complement implementation likely values are -127 and -0 respectively. When these are converted back to unsigned char during the initialization, then (if UCHAR_MAX is 255) they will be converted to 129 and 0 respectively. This is *not* intuitive. Append to 6.5.8p17: The value of each element is determined by converting the corresponding numerical representation of the mapped character, or the octal or hexadecimal escape sequence, directly to the array element type, not via the type char. Append to example 7 in 6.5.8p24: The declaration: unsigned char c [] = "\xFF"; is identical to: unsigned char c [2] = { 0xFF, 0 }; and not to: unsigned char c [2] = { (unsigned char)(char) 0xFF, 0 }; (the latter could be different if /CHAR_MAX/ is less than 255 and the implementation-defined value of the expression /(char) 0xFF/ is not equal to /254-UCHAR_MAX/).