From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mike Haertel Message-Id: <200107161834.f6GIYtl10556@ducky.net> To: 9fans@cse.psu.edu Subject: Re: [9fans] another compiler bug (another try to send this coherently) In-Reply-To: <3B512D07.97B5B213@null.net> Date: Mon, 16 Jul 2001 11:34:55 -0700 Topicbox-Message-UUID: cf1ca77c-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. Sorry, my mistake. Whatever it prints, it should print the same number twice, not two different values.