• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: gcc and bitwise right shift
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: gcc and bitwise right shift
      • From: Thierry Faucounau <email@hidden>
References: 
 >gcc and bitwise right shift (From: Thierry Faucounau <email@hidden>)

  • Prev by Date: gcc and bitwise right shift
  • Next by Date: Re: gcc and bitwise right shift
  • Previous by thread: gcc and bitwise right shift
  • Next by thread: Re: gcc and bitwise right shift
  • Index(es):
    • Date
    • Thread