Re: gcc and bitwise right shift
Re: gcc and bitwise right shift
- Subject: Re: gcc and bitwise right shift
- From: glenn andreas <email@hidden>
- Date: Tue, 17 Mar 2009 14:26:46 -0500
On Mar 17, 2009, at 2:09 PM, Thierry Faucounau wrote:
As far as I understood it, bitwise shifts using << or >> in C were
logical shifts (ie. bringing in zeros). However, I just hit a
difference in behavior between the windows compiler and gcc and I
haev to say, I sort of side with VC++ on this one.
[snip]
How odd (apart from the first one ofc). What am I missing here?
From <http://std.dkuug.dk/JTC1/SC22/WG14/www/docs/n843.htm>, ISO/IEC
standard for C, section 6.5.7 "Bitwise shift operators" #4:
"If the value of the right operand is negative or is greater than or
equal to the width of the promoted left operand, the behavior is
undefined"
So "1 >> 32" is undefined, since 32 is greater than or equal to the
width of the (promoted) left operand.
Glenn Andreas email@hidden
<http://www.gandreas.com/> wicked fun!
Mad, Bad, and Dangerous to Know
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden