On Fri, Dec 13, 2002 at 17:09:42 +0200, Ruslan Ermilov wrote: > : > : * Integer types `unsigned short' and `unsigned char' promote to > : `unsigned int'. > > With -traditional, the code I quoted still produces -1.
Probably because of machine-specific overflow handling or printf overflow.
Use this safe example instead (with -traditional):
main()
{
long long l;
unsigned char a = 1;
unsigned char b = 2;
l = a - b;
printf("%04x %04x\n", (int)((l >> 32) & 0xffff), (int)(l & 0xffff));
l = -1;
printf("%04x %04x\n", (int)((l >> 32) & 0xffff), (int)(l & 0xffff));
}
> In any case, this section doesn't apply to this case because
> no conversion described in section 6.10 is ever done here,
> since both operands are of the same type, "unsigned char".
No, any char type converted to int (or to unsigned int with -traditional)
prior to any operation with it.
--
Andrey A. Chernov
http://ache.pp.ru/
msg48647/pgp00000.pgp
Description: PGP signature
