From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mike Haertel Message-Id: <200107140326.f6E3Q7j03750@ducky.net> To: 9fans@cse.psu.edu Subject: [9fans] another compiler bug (another try to send this coherently) Date: Fri, 13 Jul 2001 20:26:07 -0700 Topicbox-Message-UUID: cd59c9c4-eac9-11e9-9e20-41e7f4b1d025 Argh, the wrong stuff got pasted on the last try and it included a ^D. This program illustrates that the integral promotions of types smaller than int will incorrectly promote unsigned char to unsigned int, rather than signed int as required by ANSI C. On a conforming implementation with 32-bit ints, this program should print "-1 -1". #include #include int main() { static unsigned char tab[1] = { 0x80 }; static int x = 0x80; printf("%d %d\n", tab[0] << 24 >> 31, x << 24 >> 31); exit(EXIT_SUCCESS); }