From mboxrd@z Thu Jan 1 00:00:00 1970 To: 9fans@cse.psu.edu From: "Douglas A. Gwyn" Message-ID: <3B512D07.97B5B213@null.net> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit References: <200107140326.f6E3Q7j03750@ducky.net> Subject: Re: [9fans] another compiler bug (another try to send this coherently) Date: Mon, 16 Jul 2001 09:05:43 +0000 Topicbox-Message-UUID: ce965bb8-eac9-11e9-9e20-41e7f4b1d025 Mike Haertel wrote: > On a conforming implementation with 32-bit ints, this > program should print "-1 -1". > static unsigned char tab[1] = { 0x80 }; > static int x = 0x80; > printf("%d %d\n", tab[0] << 24 >> 31, x << 24 >> 31); How do you figure that? The promoted tab[0] (signed int) or x left-shifted 24 places sets the sign bit, and right-shifting a negative value is implementation-defined.