On Aug 12, 2015, at 1:07 PM, Richard Sandiford <rdsandif...@googlemail.com> wrote: >> I don't think the right shifts are an issue at all. > > Well, they're implementation-defined, at least in C.
> The C11 wording for E1 >> E2 is "If E1 has a signed type and a negative > value, the > resulting value is implementation-defined”. > Is C++ different? No, it is the same: 3 The value of E1 >> E2 is E1 right-shifted E2 bit positions. If E1 has an unsigned type or if E1 has a signed type and a nonnegative value, the value of the result is the integral part of the quotient of E1 divided by the quantity 2 raised to the power E2. If E1 has a signed type and a negative value, the resulting value is implementation- defined. > (I don't have the standard handy.) Google is your friend.