------- Additional Comments From bjoern dot m dot haase at web dot de 2005-01-06 17:35 ------- It seems that the standard says that shift operations with negative shift count are supposed to yield an "unspecified" result. Is there some more specific convention for gcc on how to behave in these cases? Otherwise the only thing to do would be to fix the instruction length calculation in the back-end code. Copy from C-Standards description: http://www.open-std.org/jtc1/sc22/open/n2794/n2794.txt 6.5.7 Bitwise shift operators Syntax [#1] shift-expr: additive-expr shift-expr << additive-expr shift-expr >> additive-expr Constraints [#2] Each of the operands shall have integer type. Semantics [#3] The integer promotions are performed on each of the operands. The type of the result is that of the promoted left operand. 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.
-- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19293