Re: bits wrap when leftshifting non-constant amounts

看板FB_chat作者時間18年前 (2008/02/13 18:47), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串3/3 (看更多)
deeptech71@gmail.com writes: > My gcc 3.4.6 behaves weirdly when left shifting, and I couldn't find > any info on this. [...] It is very clear in ISO/IEC 9899:1999 =C2=A76.5.7: 3 The integer promotions are performed on each of the operands. The type of the result is that of the promoted left operand. It the value of the right operand is negative or is greater than or equal to the width of the promoted left operand, the behaviour is undefined. In other words, the result can be anything at all, and is not even required to be consistent from one evaluation to the next. In fact, gcc is free to wipe your hard drive, shoot your dog and burn down your house for all the standard cares; which I guess is a roundabout way of saying "don't do that". DES --=20 Dag-Erling Sm=C3=B8rgrav - des@des.no _______________________________________________ freebsd-chat@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-chat To unsubscribe, send any mail to "freebsd-chat-unsubscribe@freebsd.org"
文章代碼(AID): #17iih100 (FB_chat)
文章代碼(AID): #17iih100 (FB_chat)