]> git.lizzy.rs Git - rust.git/commit
auto merge of #15324 : sneves/rust/master, r=alexcrichton
authorbors <bors@rust-lang.org>
Thu, 3 Jul 2014 06:11:38 +0000 (06:11 +0000)
committerbors <bors@rust-lang.org>
Thu, 3 Jul 2014 06:11:38 +0000 (06:11 +0000)
commit00f9ff2b41ffd1f1c187533570d979018724852a
tree3213e9e5f8328493feb5bc417d55f2460f117c8b
parente6c54a12c4d209de9f438b4722657ca381f969a2
parentc0248c0839cfdf5b7030f4191ea7aed0981b9e4e
auto merge of #15324 : sneves/rust/master, r=alexcrichton

The current implementation of `rotate_left` and `rotate_right` are incorrect when the rotation amount is 0, or a multiple of the input's bitsize. When `n = 0`, the expression

    (self >> n) | (self << ($BITS - n))

results in a shift left by `$BITS` bits, which is undefined behavior (see https://github.com/rust-lang/rust/issues/10183), and currently results in a hardcoded `-1` value, instead of the original input value. Reducing `($BITS - n)` modulo `$BITS`, simplified to `(-n % $BITS)`, fixes this problem.