Re: bits wrap when leftshifting non-constant amounts
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"
討論串 (同標題文章)
完整討論串 (本文為第 3 之 3 篇):